开发者

How to subclass UIViewController with multiple nibs / xibs?

开发者 https://www.devze.com 2023-01-30 08:02 出处:网络
I would like to subclass UIViewController with multiple nibs. For example: BaseViewController has a nib with a label, and is subclassed from UIViewController

I would like to subclass UIViewController with multiple nibs.

For example:

BaseViewController has a nib with a label, and is subclassed from UIViewController

SecondViewController has a nib with a button, and is subclassed from BaseViewController.

SecondViewController should also have the label from the BaseViewController.

I have searched an not found a开发者_如何学JAVAny tutorials on this, only tutorials with ways to add UIView's to UIViewControllers, so I'm not sure this is even possible.

Can anyone explain how to do this, or point me in the direction to the resources that show how to do this (or if it's even possible at all)?


I am using a hierarchy of controllers and it works just fine. As long as your correct match nibs to properties at each level, there is no reason you cannot define parent controllers in a hierarchy.


I don't think that what you are asking can be done. A view can be loaded from only one nib. You could have the base view controller set up with a nib, and descendant view controllers do additional setup in viewDidLoad.

0

精彩评论

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

关注公众号