使用UIModalPresentationCustom解除各种视图控制器时,在解除视图控制器后,屏幕将变黑,就好像所有视图控制器都已从视图层次 struct 中移除.

正确设置转换委托,正确请求并传递animationControllerForPresentedController,动画结束后完成转换.

此代码在使用iOS 7SDK编译时运行良好,但在使用iOS 8b5编译时会损坏

推荐答案

这是因为您最有可能将演示文稿

[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]

以及提交的

[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]

在动画控制器的(void)animateTransition:(id)transitionContext方法中查看控制器到容器视图.由于您使用的是自定义模式演示,因此presenting view controller仍显示在presented view controller下方.现在,由于它仍然可见,您不需要将其添加到容器视图中.而不是go containerView.在animateTransition:method中应该是这样的

UIView *containerView = [transitionContext containerView];
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

// Boolean value to determine presentation or dismissal animation
if (self.presenting){        
    [transitionContext.containerView addSubview:toViewController.view];
    // Your presenting animation code
} else {
    // Your dismissal animation code
}

Ios相关问答推荐

Xcode15.3上的生成错误:调用的对象类型';facebook::flipper::SocketCertificateProvider';不是函数或函数指针

如何删除NavigationView中的默认透明标头?

执行devicectl:ProcessException时出错:进程异常退出:错误:命令超时超过5.0秒

Flutter iOS 键盘问题:. TextInputType.number 中缺少字符

仅更改 AttributedString 的字符串(例如 UIButton 配置 attributeTitle)

NSError 错误领域: "CBATTErrorDomain" 代码: 128 0x0000000282b111a0

创建 Flutter 项目时,如何从我的系统中删除特定的开发者身份?

如何在 SwiftUI 视图中显示协议视图?

帧过渡动画有条件地工作

SwiftUI 文本字段代理绑定代码忽略空格不起作用?

.overlay 和 body 是什么 swift 概念

辅助功能判断器无法在 macOS Monterey 版本 12.3 上的 Xcode 版本 13.3 上运行

如何将 ImageView 放置在 UIView 的中心?

如何阻止图像在 UIImageView 中拉伸?

Swift 错误:在其自己的初始值中使用的变量

在 Grand Central Dispatch 中使用 dispatch_sync

为所有 UIImageViews 添加圆角

如何在 iphone 屏幕中间显示活动指示器?

在自动布局中居中子视图的 X 会引发未准备好约束

错误 itms-90035 - Xcode