是否可以使用完成块推送视图控制器? [英] Is it possible to push a View Controller with a completion block?

查看:20
本文介绍了是否可以使用完成块推送视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UINavigationController 的文档不包含带有 completion: 参数的 pushViewController 方法.

UINavigationController's documentation contains no pushViewController methods with a completion: parameter.

推荐答案

我会同意@justMartin 的回答.但下面是另一种方法.

I would go with @justMartin's answer . But below is another approach.

推送动画需要 0.3 秒.因此,如果您想在完成后在此处运行某些功能,请在 0.3 秒延迟后使用 performSelector.

push animation take 0.3 seconds.So, if you want to run some function here after completion use performSelector after 0.3 seconds of delay.

[self performSelector:@selector(completedPushing:) withObject:nil afterDelay:.3];


在将 new viewController 推送到 navigation stack 之后,old viewController view 从视图层次结构中移除.因此这导致 viewDidDisappear 的调用 在旧的 ViewController 上.你可以在那里写你的 completion 代码.不要忘记在 viewDidDisappear 的某个实现点调用 super.

OR
After pushing the new viewController onto navigation stack,the old viewController view is removed from view hierarchy.so this results in call of viewDidDisappear on old ViewController.You can write your completion code there. don't forget to call super at some point of implementation of viewDidDisappear.

这篇关于是否可以使用完成块推送视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆