我刚刚发现该popoverPresentationControllerDidDismissPopover方法已被弃用。什么是替代方法?
Isa*_*aac 12
UIPopoverPresentationControllerDelegate协议似乎包括UIAdaptivePresentationControllerDelegate协议,其中有
// Called on the delegate when the user has taken action to dismiss the presentation successfully, after all animations are finished.
// This is not called if the presentation is dismissed programatically.
@available(iOS 13.0, *)
optional func presentationControllerDidDismiss(_ presentationController: UIPresentationController)
Run Code Online (Sandbox Code Playgroud)
并且presentationControllerDidDismiss()似乎在弹出窗口被解除时被调用。
遗憾的是,苹果的文档没有留下任何提示。我会这样解决事情。
\n\n您设置弹出窗口并获得UIPopoverPresentationController类似的结果:
UIViewController* controller = [[MyCustomViewController alloc] init];\ncontroller.modalPresentationStyle = UIModalPresentationPopover;\n\n[self presentViewController:controller animated:YES completion:nil];\n\nUIPopoverPresentationController* pc = [controller popoverPresentationController];\npc.sourceView = self.view;\npc.sourceRect = CGRectZero;\nRun Code Online (Sandbox Code Playgroud)\n\n这里的对象controller表示由 popover\xe2\x80\x94 自定义视图控制器包装的主视图控制器。我认为最好的选择是重写-viewDidDisappear:自定义视图控制器的方法。当弹出窗口呈现控制器关闭弹出窗口时,将调用该方法。
- (void)viewDidDisappear:(BOOL)animated\n{\n [super viewDidDisappear:animated];\n NSLog(@"%@ - %@", NSStringFromSelector(_cmd), self);\n // Do the needful.\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我认为苹果公司没有提供弃用的理由或如何处理的建议,这对苹果来说是一种耻辱。希望有帮助!
\n| 归档时间: |
|
| 查看次数: |
1131 次 |
| 最近记录: |