Custom UIView built using the Builder interface, available / positioned through the Interface Builder

This should not be confusing. I have a custom UIView with a bunch of controls on it. UILabels, buttons, etc. I created this Nib using Interface Builder. I want to be able to position this custom uiview on another UIView using an interface constructor.

How to associate your custom UIView class with nib? initWithCoder receives the call, but I want this class to be loaded from nib.

thanks

+6
iphone interface-builder uiview
source share
4 answers

For this to work, you must create a plug-in for Interface Builder that uses your own management class. Once you create and install your plugin, you can add and drag instances of your view to another window or view in Interface Builder. For information on creating IB plugins, see Interface Builder Plugin Programming Guide and the chapter on creating your own IB palette controls from Aaron Hillegas's book " Cocoa Programming for Mac OS X" .

Here is a link to the original author of the accepted answer to a similar question .

+3
source share

You only need to create a plugin if you want the custom view to draw correctly in the nib that you are using. You can create your own control and then show it as an empty rectangle until it is created at startup right now.

How do I get a view in Interface Builder to load a custom view in another bank?

+2
source share

You can insert a UIViewController object using Interface Builder, and then set the UIViewController "Thread Name" property. I don’t know if this will ruin your model, but I think this is the only way to do what you are trying to do.

0
source share

In IB, pick up the Identity Inspector tool (Command-4), then select your own view, and in the Class pop-up window, select the name of your custom class instead of the generic UIView. You might also want to connect it to Ivar. In your ViewController, declare an instance of your custom class with an IBOutlet in front of it. Then go back and call the Connection Inspector and connect your vision to ivar by dragging the mouse from the drop-down menu with a custom view for the file owner (which should be an instance of your ViewController) and choosing the ivar name.

When your NIB is loaded, it must create an object of this type and connect it to this variable.

0
source share

All Articles