ios - 在 iOS 11 中,UIViewController 的 transitionFromViewController 从不调用它的完成 block

标签 ios objective-c uiviewcontroller ios11

从 iOS 11 开始,UIViewControllertransitionFromViewController:toViewController:duration:options:animations:completion:方法似乎不再调用其完成 block 。

下面的示例代码片段:

[self addChildViewController:toVC];

[fromVC willMoveToParentViewController:nil];

[self transitionFromViewController:fromVC
toViewController:toVC
duration:0.4
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{}
completion:^(BOOL finished) {
    NSLog(@"Completion called"); // this completion is never executed
}];

这导致我在让我的 View 正确转换和动画时遇到各种问题。有没有其他人遇到过这种行为,和/或发现了一种解决方法?

最佳答案

所以事实证明我没有明确添加 toVC.view作为 self.view 的 subview 添加后toVC作为 self 的 subview Controller .奇怪的是,这在 iOS 11 与以前的版本中表现不同,但这确实起到了作用:

[self addChildViewController:toVC];
[self.view addSubview:toVC.view]; // This line is what is needed

[fromVC willMoveToParentViewController:nil];

[self transitionFromViewController:fromVC
toViewController:toVC
duration:0.4
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{}
completion:^(BOOL finished) {
    NSLog(@"Completion called");
}];

关于ios - 在 iOS 11 中,UIViewController 的 transitionFromViewController 从不调用它的完成 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46474965/

相关文章:

ios - 关于如何同时为不同的 UIView 设置动画的方法

ios - Google 登录不在 UIVIewController 中

ios - iPad UIViewController 复杂界面最佳实践

ios - 如何将文本居中放置在圆圈中间?

html - 在 Iphone 上查看网站时出现各种问题;网站未居中且页脚未跨越底部

ios - 静态库代码阶段项目头

ios - UIAlertView 的类别需要回调警报按钮单击 iOS

iphone - 将控制权(响应者?)传递回下部 UI​​View,同时仍在上部 UIView 上执行淡出动画

ios - 尝试获取证书时出错 : The specified item could not be found in the keychain

ios - 右标注附件方法及实现