我在这里遇到了一些问题。当我在主视图中单击我的跟踪按钮时,如果显示跟踪信息,则按钮会将我带到新视图。我遇到的一个问题是,当它移动到新视图时,任何标签都开始变小并且动画变为正常大小。我不确定我是否已经正确地解释了它,但是当我设置它时,视图是动画的。我将在下面附上代码。
感谢。
- (IBAction)ordertrack {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
[self presentViewController:vc animated:NO completion:NULL];
}
更新:
我仍然没有任何解决方案可以工作,我已经附上下面的gif来显示问题,你会看到后退按钮会调整大小。
编辑:
为Track1.m添加代码
//
// Track1.m
// uDropOff 3
//
// Created by Curtis Boylan on 06/01/2016.
// Copyright © 2016 Curtis Boylan. All rights reserved.
//
#import "Track1.h"
@interface Track1 ()
@end
@implementation Track1
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)back {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"];
[self presentViewController:vc animated:YES completion:NULL];
}
@end
答案 0 :(得分:2)
animated
上的presentViewController:animated:completion:
参数控制新视图控制器是滑动到屏幕上还是仅显示。它对新视图控制器出现后的作用没有影响。
如果新的" track1"视图控制器在其设置代码中有动画,这些动画仍然会出现。您需要构建自己的机制来告诉它不要动画。 (也许可以向dontAnimateInitialDisplay
VC添加track1
属性,并编写代码,如果dontAnimateInitialDisplay
为真,则会跳过动画。然后您将上面的代码更改为:
- (IBAction)ordertrack {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//Cast "vc" to the correct type so we have access to the
//dontAnimateInitialDisplay property
Track1VC *vc = (Track1VC *)
[sb instantiateViewControllerWithIdentifier:@"track1"];
vc.dontAnimateInitialDisplay = TRUE;
[self presentViewController:vc animated:NO completion:NULL];
}
答案 1 :(得分:1)
动画可以在您提供的track1视图控制器中实现。例如,在viewDidLoad / viewDidAppear。
中检查[UIView animateWithDuration:
...