我的 viewController 更新有问题吗?
我只是给你一个我的问题的例子:-
我已经实现了这个方法:
-(void)viewWillAppear:(BOOL)animated {
NSLog(@"update");}
在我的viewController中,但它随时被调用,我如何手动调用它?
提前致谢...
I just give u example of my problem:-
I have implemented this method:
-(void)viewWillAppear:(BOOL)animated {
NSLog(@"update");}
inside my viewController, but it's called anytime, how I can call it manually?
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[self viewWillAppear:YES];
如果您已经在对象中。[self viewWillAppear:YES];
if you are in the object already.直接调用该方法是不正确的,因为您必须在其中执行
[super viewWillAppear:animated];
。此方法是在视图出现之前进行所有必要的设置。您不知道超类
进行什么样的设置。因此,最好将您想要重用的代码部分打包到不同的方法中,并从viewWillAppear:
方法和您想要调用它的另一个方法中调用它。It wouldn't be right to call that method directly as you are bound to do
[super viewWillAppear:animated];
within it. This method is to do all the necessary set up just before the view will appear. You don't know what kind of setup thesuperclass
does. So it is better to package the part of code that you want to reuse into a different method and call it from both theviewWillAppear:
method and the other method that you want to call it from.