问题
when i load my viewController i used "viewDidLoad"method to init my view ,but this take much time to make the view appeared .So i had the idea to use "viewDidAppear" method to accelerate the appearance of my view but the load of the informations about my view are now loaded to the memory every time that i push my view (which is normal) or i pop to it(and there is my problem) Have you an idea?
回答1:
Create a background task that is started in viewDidLoad and just updates the GUI when it's finished. This should at least let you show the GUI, but possibly without valid data.
回答2:
According to the View Controller Programming Guide, you are supposed to create your view in the loadView method :
If you prefer to create views programmatically, instead of using a nib file, you do so from your view controller’s loadView method. You must override this method if you plan to create your views programmatically.
Maybe you should create your view in the loadView method and then load extra data in the viewDidLoad as explained in Understanding the View Management Cycle, using a background task as suggested by willcodejavaforfood if necessary.
回答3:
i did it with the method "ViewDidAppear:animated" and for the problem of loading data for every appearance i deal with it with a test on the top of the mehod:
if(data==nil){/*i do ...*/}
and for me data was an array that i am writing on when loading the view
来源:https://stackoverflow.com/questions/2987672/with-viewdidload-my-viewcontroller-take-much-time-to-appear