Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create custom reusable UIControls in XCode 4.1

I want to create a custom UIProperty Control that is not more than a UILabel and a UITextField grouped together and add it to IB's Custom Objects list to reuse in other Nibs. I found a lot of documentation and everything points to creating a Xcode or IB plugin project, but everything refers to Xcode 3.x and there are no parallels in many spots. Anyone cares to help?

Thank you in advance

like image 909
Pedro Borges Avatar asked Nov 05 '22 15:11

Pedro Borges


1 Answers

Unfortunately, it's not easy, if even possible at all. Unlike Xcode 3, in XCode 4, Apple has pretty much eliminated this feature. They now say you must create the class manually first and then associate the controller object using Interface Builder.

InterfaceBuilder Docs explain how to do it now in Xcode 4 using a custom object.

And from the xcode 4 transition guide:
After adding the source file templates to your project, drag a custom view object from the library into the nib file. After adding the custom view to your nib, select the custom view and assign the correct class to it in the class field under Custom Class in the Identity inspector

Some more resources:

iphone-creating-custom-objects-for-interface-builder

Interface Builder Help - Custom Object

like image 192
chown Avatar answered Nov 14 '22 06:11

chown