Create an Outlet in Storyboard to an Inherited Property

Create an outlet in storyboard to an inherited property

You can ctrl-drag the UIButton from your storyboard to your BasicController for each subclass you have laid out in your storyboard. You can then use the buttonThing in each subclass as usual.

Remember to link your subviewcontrollers to their respective viewcontrollers in the storyboard.

Inherit outlets and actions in view controller


So the question is there any way to use one set of iboulets and ibactions in RoomViewController class and inherit them for example in Room1ViewContoller?

The @IBOutlet properties and @IBAction methods you declare in RoomViewController are inherited by subclasses such as Room1ViewController.

But what is not inherited is the design in the nib. When you instantiate a subclass like Room1ViewController, it loads its own view, not some other view controller's view. This loading takes place on a per-instance basis. Therefore, you still need to hook up the interface objects in the nib to the properties and methods in the class declaration. In other words, you still need to make outlets and actions in the nib, because this is a different view.

How do I subclass a variable with an IBOutlet?

Just add the IBOutlet modifier in the superclass.

Storyboards: How to add outlets to a prototype UITableViewCell?

With any object you can create with IB, you can assign it to a different class (one that you wrote). This is not different for cells. In the same way you can make IB instantiate MyFooView instead of UIView (MyFooView being derived from UIView), you can do the same for the cells.

Click your cell, click the 3rd icon on the shelf to the right. You will see a section called "Custom Class" and a text field called Class. Select the new class you've just created that is derived from UITableViewCell (let's call it MyCell). You can add IBOutlets to the MyCell class.

Connect outlet from file to storyboard in Xcode 7

Ok, solved. I'm able to connect outlet from connection inspector in Utilities panel.

IBOutlet Connections and Inheritance

Within Interface Builder, select the Identity Inspector from the Utilities pane. In the Custom Class section, fill out your required subclass there.

Then select the Connections Inspector and hook-up your required outlets.

Repeat this for each UIView you have.

Sample Image



Related Topics



Leave a reply



Submit