是否可以使用完成块推送View Controller? [英] Is it possible to push a View Controller with a completion block?
问题描述
UINavigationController的文档不包含 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];
OR
推送<$ c后$ c> new viewController 到导航堆栈
,从视图中删除旧viewController视图
hierarchy.so这会导致在旧的ViewController上调用 viewDidDisappear
。您可以在那里编写完成
代码。不要忘记在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.
这篇关于是否可以使用完成块推送View Controller?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!