popViewController的完成块
问题说明
当使用 dismissViewController
关闭模态视图控制器时,可以选择提供完成块。是否有类似的等价物 popViewController
?
When dismissing a modal view controller using dismissViewController
, there is the option to provide a completion block. Is there a similar equivalent for popViewController
?
完成参数相当方便。例如,我可以使用它来阻止从表格视图中删除一行,直到模态在屏幕外,让用户看到行动画。
The completion argument is quite handy. For instance, I can use it to hold off removing a row from a tableview until the modal is off screen, letting the user see the row animation. When returning from a pushed view controller, I would like the same opportunity.
我已经尝试将 popViewController
放在 UIView
动画块,我可以访问完成块。但是,这会对弹出的视图产生一些不必要的副作用。
I have tried placing popViewController
in an UIView
animation block, where I do have access to a completion block. However, this produces some unwanted side effects on the view being popped to.
如果没有可用的方法,有什么解决方法?
If there is no such method available, what are some workarounds?
正确答案
我知道两年前已经接受了一个答案,但这个答案不完整。
I know an answer has been accepted over two years ago, however this answer is incomplete.
没有办法做你想要的开箱即用的
There is no way to do what you're wanting out-of-the-box
在技术上是正确的,因为 UINavigationController
API不提供任何选项。然而,通过使用CoreAnimation框架,可以向底层动画添加完成块:
This is technically correct because the UINavigationController
API doesn't offer any options for this. However by using the CoreAnimation framework it's possible to add a completion block to the underlying animation:
[CATransaction begin];
[CATransaction setCompletionBlock:^{
// handle completion here
}];
[self.navigationController popViewControllerAnimated:YES];
[CATransaction commit];
完成块将在 popViewControllerAnimated:
结束。此功能自iOS 4开始可用。
The completion block will be called as soon as the animation used by popViewControllerAnimated:
ends. This functionality has been available since iOS 4.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcgkefa
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20