• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

popViewController的完成块

用户头像
it1352
帮助1

问题说明

当使用 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?

正确答案

#1

我知道两年前已经接受了一个答案,但这个答案不完整。

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
系列文章
更多 icon
同类精品
更多 icon
继续加载