Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dale.albiston

macrumors member
Original poster
Sep 29, 2006
61
0
I'm looking to have a dynamic element in the UI of a project, specifically it will be something like an object inspector (it will process config files for an application).

I can do this using a tableview as long as i edit everything as text (it will be stored as text), however what I would like to do is have differing controls for some rows. e.g. if the allowed text is '0' or '1' then using a checkbox makes sense, for slightly longer lists a combo box makes sense. for some just a plain text box works fine.

Question: is it possible to have different cell types in a single table column? and if so how?

I'm sort of assuming I'll need to have a single cell type, which would be a custom control that can appear as one of several child controls but I'm not too sure how to manage this.

searching for cocoa dynamic user interface in google hasn't exactly helped.

another alternative i suppose is to create controls manually in a scrollbox (i.e. drop the table totally), but i'd prefer to use a table if possible.

also: is it possible for table rows to have different row heights? or must they all be the same?

pointers on were to look for this sort of information greatly appreciated, the apple documentation is good on syntax but short on examples...
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Yes you can have different stuff on different rows. You do it using the table view delegate method to alter or switch the cell on the row as it gets drawn.

The method in question is tableView:shouldEditTableColumn:row:.

Note that this assumes that you have the same cell for each row. If you want to have different cells I'd have thought you could use your own Cell class that calls the appropriate method in the other cell classes when asked to draw etc...

Or you could follow this very short example here
 

dale.albiston

macrumors member
Original poster
Sep 29, 2006
61
0
Yes you can have different stuff on different rows. You do it using the table view delegate method to alter or switch the cell on the row as it gets drawn.

The method in question is tableView:shouldEditTableColumn:row:.

Note that this assumes that you have the same cell for each row. If you want to have different cells I'd have thought you could use your own Cell class that calls the appropriate method in the other cell classes when asked to draw etc...

Or you could follow this very short example here

I thank you.. this looks like it will actually do what I'm after from a visual point of view, but its looking like I'll be creating a custom cell view to pass much of the handling logic into one place.

Thanks for the links though, most helpful :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.