我写了一个自定义UIStoryboardSegue
,我正用它来在各种UIViewControllers
之间转换。动画按需要工作,大部分时间显示为我在模拟器和设备上预期的那样。如何防止在自定义UIStoryboardSegue结束时出现“闪烁”的视图?
然而,SEGUE完成后,有时,我可以看到老UIViewController
闪存一秒钟的UIStoryboardSegue
完成后,一小部分。结果扰乱了我期待的平稳过渡。不幸的是,我无法辨别出这种行为的任何模式。
我已经包含了一个我正用来管理下面的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;
}
}
我正在尝试的一个建议是:为所有CAAnimation实例设置'removedOnCompletion = NO'和'fillMode = kCAFillModeForwards'。也许他们正在重置。 –