viewDidLoad in iPhone
What 开发者_Go百科is ViewDidLoad()
method for?
This function is executed, when the view controller loaded your view sucessfully - and you can do there your custom initializations as well.
If you are new to iPhone development, take a look at the apple reference: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
I have seen too many times -viewDidLoad
used to setup the view controller's title, navigationItem, tabBarItem or any of the properties of these, such as the right/leftBarButtonItems on navigationItem. This is is not advised, because these properties may be needed before the view is loaded.
As an example, a tab bar controller needs each view controller's tabBarItem but won't load the view to the unselected tabs; So -viewDidLoad
won't be called before the tabBarItem is needed.
It's called when the view loaded. Is it really that complicated??
精彩评论