gpt4 book ai didi

ios - 弹出窗口关闭后如何在 transitionCoordinator 中安排新的演示文稿

转载 作者:行者123 更新时间:2023-11-29 02:31:49 28 4
gpt4 key购买 nike

我正在更新我的应用程序以支持 iOS 8。在一些地方,我在弹出窗口关闭后进行了模式演示。这是我用于 iOS 7 的代码

[self.POP dismissPopoverAnimated:YES];
// initialization code for self.SMVC
MPTAdvancedSearchNav* nav = [[MPTAdvancedSearchNav alloc]initWithRootViewController:self.SMVC];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentViewController:nav animated:YES completion:nil];

当我在 iOS 8 设备上运行它时,我看到在 UIModalPresentationFormSheet 动画开始之前有延迟(大约 1/4 秒)。

我做了一些研究并找到了这个 WWDC 视频 https://developer.apple.com/videos/wwdc/2014/#214 (第 29 分钟)说我应该使用过渡协调员在弹出窗口关闭后安排新的演示文稿。

问题是,我不知道该怎么做。我想我应该使用

- (void)notifyWhenInteractionEndsUsingBlock:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))handler

这是我应该使用的方法吗?另外,我如何获得 UIViewControllerTransitionCoordinatorContext

最佳答案

不幸的是,Popovers 仅在 iOS 8 中转换为“演示样式”,因此您仍然需要 iOS 7 的旧代码,并且有一个用于 iOS 8 特定代码的分支。最重要的是,为了让一切顺利进行,您必须放弃 UIPopoverController,因为它不是从 UIPresentationController 继承的,而 UIPresentationController 是连接到 iOS 8 中专门用于弹出窗口的转换系统的要求。所有 UIPopoverController 在 iOS 8 中所做的就是包装 UIPopoverPresentationController。

但是,我认为有一个更简单的解决方案,可以在 7 和 8 中很好地工作:让任何正在创建/演示 MPTAdvancedSearchNav 的类成为 UIPopoverController 的委托(delegate),并实现 didDismissPopover:,并将代码移到那里将进行演示。

查看此处的文档,并让我知道它是如何工作的 - https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIPopoverControllerDelegate_protocol/index.html#//apple_ref/doc/uid/TP40009307

关于ios - 弹出窗口关闭后如何在 transitionCoordinator 中安排新的演示文稿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26767026/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com