我正在使用控制器包含API实现自定义的segue,没有presentViewController的自定义Segue没有正确地展开
@implementation CustomSegue
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *destinationViewController = self.destinationViewController;
[sourceViewController addChildViewController:destinationViewController];
destinationViewController.view.alpha = 0.0;
[sourceViewController.view addSubview:destinationViewController.view];
[UIView animateWithDuration:0.3 animations:^{
destinationViewController.view.alpha = 1.0;
} completion:^(BOOL finished) {
[destinationViewController didMoveToParentViewController:sourceViewController];
}];
}
@end
视图控制器的层次结构很简单:sourceViewController → destinationViewController
当从destinationViewController
在[UIStoryboardUnwindSegueTemplate _perform:]
有例外Could not find a view controller to execute unwinding for <…>
展开到sourceViewController
,应用程序崩溃我没有实现自定义-[UIViewController viewControllerForUnwindSegueAction:fromViewController:withSender:
或 -[UIViewController canPerformUnwindSegueAction:fromViewController:withSender:
这意味着框架返回正确的值(虽然我实现了它一次检查)。
在segue中将我的自定义addChildViewController:…
代码替换为presentViewController:…
时,它工作正常:展开按预期执行。
问题:是否有可能创建自定义视图控制器层次结构的自定义segue?
测试用例项目:https://bitbucket.org/zats/unwind/
不要认为它会解决您的问题,但是......您应该确实有一个包含源控制器的容器控制器,然后将目标控制器添加到容器中。然后做动画,然后删除源控制器。将目标控制器添加到源控制器有点奇怪。下面是一个执行的例子,它可以正确调用正确的东西,并更改视图控制器层次http://pastebin.com/Vk9JfcmP。可能有些用处? –
它并没有真正改变代码崩溃的事实:)目前,层次结构对我而言并不重要 –
可能是因为腐败的层次结构导致问题,尽管... –