如何在popover解雇后在transitionCoordinator中安排新的演示文稿

时间:2014-11-05 21:00:59

标签: ios uiviewcontroller ios8 uipopovercontroller

我正在更新我的应用程序以支持iOS 8.在一些地方,我在popover解雇后进行模态演示。这是我用于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分钟)说我应该使用转换协调员在解雇popover后安排新的演示文稿。

问题是,我无法弄清楚如何做到这一点。我想我应该用

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

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

1 个答案:

答案 0 :(得分:1)

不幸的是,Popovers只在iOS 8中被转换为“演示风格”,所以你仍然需要你为iOS 7提供的旧代码,并且在那里有一个用于iOS 8特定代码的分支。最重要的是,为了使一切运行良好,你将不得不放弃UIPopoverController,因为它不会从UIPresentationController继承,这是一个特殊的连接到iOS 8转换系统的要求。 iOS 8中的所有UIPopoverController都包含UIPopoverPresentationController。

但是,我认为有一个更简单的解决方案,可以很好地适用于7&amp; 8:让任何类正在创建/呈现MPTAdvancedSearchNav成为UIPopoverController的委托,并实现didDismissPopover:,并将你的代码移动到那里进行演示。

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