【问题标题】:Custom UIViewController Transition by using custom segue class使用自定义 segue 类自定义 UIViewController 转换
【发布时间】:2014-11-19 09:11:06
【问题描述】:

我试图通过使用自定义 segue 并实现 segue 类来实现自定义过渡样式以淡入新的 Viewcontroller。 我几乎设法实现了这一点,但每次运行应用程序时都会收到警告/错误:

“开始/结束外观转换的不平衡调用。”

虽然应用程序一直运行良好,但动画期间还是有一点闪烁。

这是我的代码:

    @implementation BlurredFadeSague

- (void)perform{

    UIViewController *sourceViewController = self.sourceViewController;
    UIViewController *destinationViewController = self.destinationViewController;

    [sourceViewController.view addSubview:destinationViewController.view];

    destinationViewController.view.alpha = 0.0f;

    [UIView animateWithDuration:0.5f
                          delay:0.1f
                        options:UIViewAnimationOptionCurveLinear
                     animations:^{
                         destinationViewController.view.alpha = 1.0;
                     }
                     completion:^(BOOL finished){
                         [destinationViewController.view removeFromSuperview];
                         [sourceViewController presentViewController:destinationViewController animated:NO completion:NULL];
                     }];

}

@end

我将转换形式称为 IBAction,如下所示:

 [self performSegueWithIdentifier:@"blurred" sender:self];

但是我得到了 consol 警告/错误:

 Unbalanced calls to begin/end appearance transitions for
 <DeviceControlViewController: 0x17597050>.

很高兴得到任何帮助, 最好的 vinc。

【问题讨论】:

  • 我不知道你是否还在为这个问题而苦恼,但我猜你会得到这个错误,因为你没有告诉 UIKit 你正在移动视图控制器。当视图控制器移动到其他窗口或父视图控制器时,您应该使用willMoveToParentViewController:willMoveToWindow: 向视图控制器声明,使用nil 指示它何时被移除。

标签: xcode segue xcode6 uiviewanimation uiviewanimationtransition


【解决方案1】:

您提到您从按钮操作中调用了 segue。您是否也将 segue 绑定到该按钮?如果是这样,您可能会调用 segue 两次。这导致第二次调用在第一次完成之前完成,从而导致“不平衡”。

【讨论】:

    猜你喜欢
    • 2016-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多