Interface Builder outlets managing

I want to create UIViewController subclass that will be container for two other controllers and it has properties

@property (nonatomic, strong) UIViewController *firstController;
@property (nonatomic, strong) UIViewController *secondController;

then i wanted to connect these properties via interface builder to instantiate them automatically. But if i just make them IBOutlets

@property (nonatomic, strong) IBOutlet UIViewController *firstController;
@property (nonatomic, strong) IBOutlet UIViewController *secondController;

i cant connect other controllers. but UINavigationController has property rootViewController and we can connect other controllers in IB. if it's possible to make such trick in custom controllers please help


You can't connect outlets from one controller to another controller -- outlets only work within a controller, not across controllers.

If you want a controller to be a container for two other controllers, you should drag two container views into your controller's view in the storyboard. You will automatically get two controllers connected to those container views with embed segues.


It should work the way you have it now. Are you sure you're adding View Controller objects in your XIB? Your UIViewController subclass xib file should look like this:

在这里输入图像描述

Then you should be able to right-click and drag the connections for firstController and secondController.

链接地址: http://www.djcxy.com/p/24410.html

上一篇: F#中的自定义计算表达式

下一篇: Interface Builder网点管理