将两个不同的storyboard viewcontrollers连接到同一个类

时间:2023-01-22 12:08:53

I am new to Iphone development. My app consists of two storyboards one for the Ipad and other for the Iphone.Now, my problem is I have an IBOutletCollection of UILabels hooked up as a property with one of the viewcontrollers in my Iphone storyboard..How am I suppose to hook up the same Ipad storyboard viewcontroller with the IBOutletCollection of UILabels for the same class..? Thanks in advance..

我是Iphone开发的新手。我的应用程序包含两个故事板,一个用于Ipad,另一个用于Iphone.Now,我的问题是我有一个UOabel的IBOutletCollection作为一个属性与我的Iphone故事板中的一个viewcontrollers挂钩..我怎么想连接与同一类的UILabels的IBOutletCollection相同的Ipad故事板视图控制器..?提前致谢..

1 个解决方案

#1


1  

Just like you'd hook up any other IBOutlet, IBOutletCollection or IBAction.

就像你连接任何其他IBOutlet,IBOutletCollection或IBAction一样。

Your UIViewController sub-class contains the bits which let you hook something in a storyboard to it.

您的UIViewController子类包含的位可以让您将故事板中的内容挂钩到它。

@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *tabButtons;

In your storyboard, you can assign the view controller to be of a certain class, in this case it will be a your UIViewController sub-class. Now all you have to do it drag the storyboard artifacts to your existing IBOutlet stubs. It works.

在您的故事板中,您可以将视图控制器指定为某个类,在这种情况下,它将是您的UIViewController子类。现在,您只需将故事板工件拖到现有的IBOutlet存根中即可。有用。

You can do this for multiple storyboards using the same class (or multiple view controller in the same storyboard too). When you load it into memory, you specify the item in the storyboard, then the storyboard creates and instance of the view controller and hooks up all the references, so all is good.

您可以使用同一个类(或同一故事板中的多个视图控制器)为多个故事板执行此操作。当您将其加载到内存中时,您在故事板中指定项目,然后故事板创建视图控制器的实例和实例并挂钩所有引用,因此一切都很好。

MyViewController *myVC = [storyboard instantiateViewControllerWithIdentifier:@"foo"];

#1


1  

Just like you'd hook up any other IBOutlet, IBOutletCollection or IBAction.

就像你连接任何其他IBOutlet,IBOutletCollection或IBAction一样。

Your UIViewController sub-class contains the bits which let you hook something in a storyboard to it.

您的UIViewController子类包含的位可以让您将故事板中的内容挂钩到它。

@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *tabButtons;

In your storyboard, you can assign the view controller to be of a certain class, in this case it will be a your UIViewController sub-class. Now all you have to do it drag the storyboard artifacts to your existing IBOutlet stubs. It works.

在您的故事板中,您可以将视图控制器指定为某个类,在这种情况下,它将是您的UIViewController子类。现在,您只需将故事板工件拖到现有的IBOutlet存根中即可。有用。

You can do this for multiple storyboards using the same class (or multiple view controller in the same storyboard too). When you load it into memory, you specify the item in the storyboard, then the storyboard creates and instance of the view controller and hooks up all the references, so all is good.

您可以使用同一个类(或同一故事板中的多个视图控制器)为多个故事板执行此操作。当您将其加载到内存中时,您在故事板中指定项目,然后故事板创建视图控制器的实例和实例并挂钩所有引用,因此一切都很好。

MyViewController *myVC = [storyboard instantiateViewControllerWithIdentifier:@"foo"];