This blog post asks the very question I have: How can one visually manage toolbar items in Interface Builder? Sure one can use this technique for the top level view, but what about other views? Is there no way I can give my design partner the ability to edit the toolbar items directly in such a view without the hack of creating a placeholder UIToolbar that’s never actually used?
Share
Here’s how I did it. I added this property to my controller
@interface:In the
@implementation, I added:Then, in the nib, I had all of the
UIBarButtonItems in aUIToolbar. In the “Objects” navigator, I selected them all, then moved them out of the UIToolbar, so that they have no view that they are a part of. Then, for each one, I right-clicked, and dragged the circle next to “New Referencing Outlet Collection” to “File’s Owner”, and selectedtoolbarItemsin the resulting popup. And now, all of the UIBarButtonItems just magically appear in the UIToolbar, no more work necessary.Alas, this is not ideal. Now that the
UIBarButtonItemsare not in aUIToolbarin the nib, they are completely invisible interface builder. They are still in the “Objects” navigator, but one cannot actually see what they look like. This seems like an unfortunate bug (filed as rdar://11234043).The other issue is that there is no way to see the order of the items in the
IBOutletCollection, as far as I can tell. I added them in the order I want them displayed, right-to-left, but it will be a PITA if I ever need to change the order or add new ones somewhere in the middle.Here’s hoping Apple adds nicer
IBOutletCollectionsupport to interface builder, with visible containers of some kind.