【发布时间】:2013-12-07 01:47:25
【问题描述】:
我正在实现自己的导航控制器,并且正在伪造添加新视图的动画,就像在 UINavigationContoller 中一样。
下面的代码效果很好,但是如果我移动-addSubview:,在 UIView 动画调用之前,它会在 ios7 中动画,但在 ios6 中没有,问题是为什么? (我的意思是,为什么会有所不同,因为动画将被调度和异步执行,对吧?或者我可能会认为它会以某种方式影响动画的开始状态?)
- (void)didAddViewControllerInNavigationStack:(NSArray*)navigationStack
{
if (self.activeViewController) {
[self.activeViewController viewWillDisappear:YES];
[self.activeViewController viewDidDisappear:YES];
}
self.activeViewController = navigationStack.firstObject;
if (!self.activeViewController) return;
CGRect windowRect = [[UIScreen mainScreen] bounds];
windowRect.origin.x = windowRect.size.width;
self.activeViewController.view.frame = windowRect;
[self.activeViewController viewWillAppear:YES];
[UIView transitionWithView:self.view
duration:0.32
options:UIViewAnimationOptionCurveEaseOut
animations:^ { self.activeViewController.view.frame = [[UIScreen mainScreen] bounds]; }
completion:^(BOOL isDone){[self.activeViewController viewDidAppear:YES];}];
[self.view addSubview:self.activeViewController.view];
[UIView commitAnimations];
}
【问题讨论】:
标签: ios objective-c animation