我编写了一个自定义UIStoryboardSegue
,用于在各种UIViewControllers
. 动画按预期工作,并且大部分时间UIStoryboardSegue
显示在模拟器和设备上都符合我的预期。
但是,有时在 segue 完成后,我可以在完成后的几分之一秒内看到旧的UIViewController
flashUIStoryboardSegue
。结果破坏了我所期待的平稳过渡。不幸的是,我无法辨别这种行为的任何模式。
我已经包含了我用来管理下面的 segue 的方法的准系统版本。是否有更可靠的方法来确保平稳过渡?难道我做错了什么?同样,大部分时间segue看起来正是我想要的方式。
- (void)perform
{
self.window = [[[UIApplication sharedApplication] delegate] window];
UIViewController *source = (UIViewController *) self.sourceViewController;
UIViewController *dest = (UIViewController *) self.destinationViewController;
[self.window insertSubview:dest.view.window belowSubview:source.view];
self.segueLayer = [CALayer layer];
// Create and add a number of other CALayers for displaying the segue,
// adding them to the base segueLayer
// Create and add CAAnimations for animating the CALayers
// (code omitted for the sake of space)
[self.window addSubview:dest.view];
[self.window.layer addSublayer:self.segueLayer];
[source.view removeFromSuperview];
}
- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)isFinished
{
UIViewController *source = (UIViewController *) self.sourceViewController;
UIViewController *dest = (UIViewController *) self.destinationViewController;
if (isFinished)
{
// Remove and deallocate the CALayers previously created
[self.segueLayer removeFromSuperlayer];
self.segueLayer = nil;
self.window.rootViewController = dest;
}
}