开发者

Where To Call Custom Method? viewDidLoad, viewWillLoad

开发者 https://www.devze.com 2022-12-22 12:43 出处:网络
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] (initWithNibN

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消