我有一个UIViewController,在其中有一些动画。在这个UIViewController上动画的UIView具有不同的起始位置和结束位置。我还有一个segue,它将推入新的UIViewController到场景中。一切都正常工作,但是如果我返回到我的第一个UIViewController,我的UIVIew的位置会改变到起始位置。
我该如何解决这个问题?
- (void)viewDidLoad
{
[super viewDidLoad];
[UIView animateWithDuration:0.3 animations:^{
self.myView.center = CGPointMake(self.myView.center.x,self.ahotherView.center.y);
}completion:^(BOOL complete){
}];
}
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
self.myView.center = CGPointMake(self.myView.center.x, self.ahotherView.center.y);
}
UIView
会跳到最终位置(想要没有这个跳跃)。为了解决这个问题,我会在- (void)viewWillLayoutSubviews
中更改代码。 - Dima Deplov