简体   繁体   English

重新加载UIViewController

[英]reload UIViewController

I have a certain code that is executed on the viewDidLoad() of a UIViewController I have. 我有在UIViewController的viewDidLoad()上执行的某些代码。 The problem is that it is only loaded for the first time only. 问题在于它仅是第一次加载。 After it is loaded the first time and I switch to some other view and come back to this view, it doesn't call the viewDidLoad again. 第一次加载后,我切换到其他视图并回到该视图,它不会再次调用viewDidLoad。 So where should I put this code at so that everytime this view is displayed it executes this code? 那么我应该在哪里放置此代码,以便每次显示此视图时都执行此代码?

我想在viewWillAppear祝你好运

You should put it in - (void)viewDidAppear:(BOOL)animated . 您应该将其放在- (void)viewDidAppear:(BOOL)animated This gets called every time your view comes on screen. 每当您的视图出现在屏幕上时,都会调用此方法。

Please refer to life cycle of iphone application 请参考iPhone应用程序的生命周期

- (void)viewDidLoad

should only be called once. 只能调用一次。

so you should use,since this method is called each & every time the View is called 所以您应该使用,因为每次调用View时都会调用此方法

- (void)viewWillAppear:(BOOL)animated

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM