Where To Call Custom Method? viewDidLoad, viewWillLoad
I am loading some info from a server. I have created a separate method to do this. I am then calling [self myCustomMethod] to run the method. No matter where I call [self myCustomMethod] (initWithNibName, viewDidLoad, viewWillLoad, viewWillAppea开发者_Go百科r, viewDidAppear), the custom method is getting called twice - what's the deal?
Are you sure you aren't instantiating your UIViewController
twice? Or call any of these methods yourself at some point? initWithNibName
will only be called once, the other methods may be called more than once in the life span of a UIViewController
. This doesn't mean however that initWithNibName
is the best place to call your method. It depends on exactly what it does, for example, wether it needs to do anything with the view.
精彩评论