I have a tab bar application and i am enc开发者_StackOverflow中文版ountering a strange behaviour....when i toggle the tab bar and reaches into new view controllers sometimes the viewDidLoad of these view controllers are getting called...though viewDidLoad should get called only first time... can anyone tell...any suggestion??
If there's a low memory warning then a tab bar controller will release all views that are not visible. This means that you can get viewDidLoad called more than once because the view has been unloaded.
Is your app memory-intensive, perhaps to the point that you're receiving memory warning? Though I have not experienced the behavior you're describing, it's possible that due to heavy memory use your unseen views are being released due to a lack of memory. When they're next called into view they would need to be reinitialized, calling viewDidLoad
.
Are you sure it's viewDidLoad, not viewWillAppear?
viewDidLoad will only be called once in each UIViewController subclass, so if your layout is like this:
-UITabBarController:
- HappyUIViewController
- SadUIViewController
- ThirdUIViewController
Then viewDidLoad will be called three times. Once for HappyUIViewController, once for SadUiViewController, and so on.
精彩评论