9

I want to build a custom control to reuse in my project which consists of two UITextFields that are linked together + a label.

It is starting to become repetitive across my App and smells of code duplication ;)

However, I wonder what is the best aproach here.

Is it best do everything by code in a controller or is posible do a visual thing like the ones built-in in Xcode?

Jason Coco
  • 77,985
  • 20
  • 184
  • 180
mamcx
  • 15,916
  • 26
  • 101
  • 189

3 Answers3

7

You can build an Interface Builder plug-in for this. It's fairly straight-forward. To get started, read the Interface Builder Plug-In Programming Guide. It even has a quick, step-by-step tutorial to get you started. Apple recommends creating a plug-in to IB for just your case...

Jason Coco
  • 77,985
  • 20
  • 184
  • 180
  • 3
    The link has changed to this: http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/IBPlugInGuide/Introduction/Introduction.html – Aaron Sep 08 '09 at 21:57
  • 1
    From that link: "Important: Interface Builder supports the creation of plug-ins for Mac OS X Cocoa-based views, controls, and objects only. You cannot create plug-ins for iOS Cocoa Touch or Mac OS X Carbon-based objects." So, no, it won't work for iOS/iPhone projects. – Gorm Feb 11 '11 at 19:24
  • 1
    The updated link has also changed: I managed to found [here}(http://www.filibeto.org/unix/macos/lib/dev/documentation/DeveloperTools/Conceptual/IBPlugInGuide/IBPlugInGuide.pdf} – Saran Aug 24 '11 at 13:44
6

I don't think this is possible. I briefly looked at the IB Plug-In Programming Guide and apparently Interface builder plugins are implemented through Custom Cocoa Frameworks. That is, your plugin is defined in a framework which is loaded in Interface Builder. IB looks in the current projects frameworks to find any custom components defined and will load plugins accordingly. It is not possible to use custom or third party frameworks on the iPhone so I don't see how IB would make a connection here. If somebody has more info I'd love to see this discussion continued.

Cliff
  • 10,586
  • 7
  • 61
  • 102
1

This is fine except it is for the iPhone. The iPhone presents a more difficult environment to create the plug-in for interface builder. It should be possible but I have yet to see a Xcode project that does this. They are all limited to creation of desktop "AppKit" versions, not iPhone "UIKit" versions of the plugins for IB.

logancautrell
  • 8,762
  • 3
  • 39
  • 50