views:

199

answers:

1

Hi, I am trying to create a matrix of buttons in Interface Builder 3.2.1 but can not find anyway to do it. I read the question and answer posted here:

http://stackoverflow.com/questions/1771835/how-to-create-a-nsmatrix-of-nsimagecell-in-interface-builder-in-10-6

But following Layout > Embed Objects In, as suggested, I see only View and Scroll View as options, not Matrix. Have I missed something?

Thanks.

A: 

I have just tried it on IB 3.2.2: Drag the button on the window, make sure it is selected (only click it once until you can see the eight blue handles around it, not twice!). In this situation the menu Layout -> Embed Objects will have the Matrix option available.

Now you can option-click and drag the lower handle of the button to add more buttons horizontally. Similarly, you can add buttons to the left, to the right or at the top, thereby creating the desired matrix of buttons.

EDIT: This recipe only works when developing for MacOS, not for iPhoneOS. I am not aware of an equivalent of NSMatrix on the iPhone. I guess the UI is simply meant to not include such elements.

user8472
Sorry, its still not working for me. I am using IB 3.2.2 now but still no luck. Here is a screen shot showing what it looks like for me:Screen shot 2010-05-29 at 11.07.25 AM
Jake
It wont let me fix that copy/paste fail. Here is a link to the screenshot: http://farm5.static.flickr.com/4020/4650681466_75208271ce_b.jpg
Jake
As far as I can see you are developing for the iPhone. `NSMatrix` is a subclass of `NSControl` and only available on MacOS; although there is an equivalent class named `UIControl` to `NSControl` on iPhoneOS, it has no matrix equivalent subclass. I guess the UI is simply meant to not use such elements.
user8472
Thanks for your replies, I had not thought that the difference in platforms would be so great for something as seemingly fundamental as this. Would you suggest then that I implement my own subclass of UIControl? My goal is to have a grid of buttons which are aware of each other's states.
Jake
I am not sure what is the best way in your case. Please have a look at this thread: http://stackoverflow.com/questions/662646/radio-button-in-iphone-app for several suggestions on what you could do.
user8472