简体   繁体   中英

Adding UIControl subclass in loadView crashes iphone app

I'm new to iPhone and experimenting with the platform. I have a root view controller which loads it's view from a nib. I accidentally uncommented the loadView method in this class, and now the app crashes - is this because if a view controller is initiated from a nib then you can never have a loadView implementation?

If you create your view using a nib file then you should override viewDidLoad and add your subviews there. You only want to override loadView when you are creating all your views programatically.

Here's a link to the UIViewController documentation which has a little bit longer explanation under the entries for loadView and viewDidLoad.

I was confused by the same issue at first...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM