Making custom table cells for view-based tables on mac?
Making custom table cells for view-based tables on mac?
- Subject: Making custom table cells for view-based tables on mac?
- From: Alex Hall <email@hidden>
- Date: Mon, 23 Nov 2015 19:06:15 -0500
Hello list,
My Twitter app is working well with its Cocoa bindings and default table cells, but I want to do more with said table cells. Right now, I put *all* the text into the cell's label, which works fine. I'd like to put the sender, tweet text, and timestamp each in their own fields, though, on the assumption that this will look better. I'll also want to display thumbnail images for tweets that include them, again as part of a cell.
When I look at the cell I got by default, it has a lot of levels to it. I'm not sure where to add my own views, or how to assign a separate view controller to the cell (just for modularity's sake). What I see is this:
Tweet cell contains: table cell view, text cell..
Tweet Cell -> table cell view contains: table view cell
table view cell contains: table view cell (yes, a second one)
I believe I'd add my views to the top level, so they are on the same level as the text cell, but I'm not sure. The docs say I should have a label and an image for free, but I don't see either one here. Furthermore, I want my image on the right, not the left, unless there's a HIG reason not to do that? Even if the thumbnails end up being on the left, I want to understand how to change that if I ever wanted to.
Once I get my views in place, I'll have to hook them to the view controller, correct? Normally I'd not even ask this, but I had to hook up nothing, and my cell already has a label that's not an outlet, so I'm not sure if special rules apply to cells.
Can I have a separate view controller for my cell, just to keep things organized? I tried to have one for a scroll area inside my main scene, but Xcode wouldn't let me. It seems I can have one controller per scene?
According to one doc I was reading, VoiceOver automatically speaks the contents of a cell's text field. What if there are multiple ones, though? Or if I want VO to ignore the image cell but speak other cells in the row? Or speak something different--can I add an accessibility description to a whole cell to have VO speak that? If so, it'll be interesting to see if I have to interact with the table first, or if not interacting still reads the description instead of the text.
Am I confusing multiple fields per cell with multiple cells? I know I can have columns in a Mac table, unlike on iOS, but I don't really want that, I don't think. If I use multiple columns, once a VoiceOver user interacts with the table, up/down move by cell, not by row. Thinking about it, that might be good in some situations… Visually, is there value to having multiple columns versus multiple text labels in a single column? Would the answer change if I decided to add a button to each table row, to open a popover with additional details about the tweet? That is, would be button have to be its own cell, or could I still add it to a single cell and have it look okay?
Making something that speaks well using VoiceOver is turning out to be way easier than making something that looks good visually, which is ironic considering how often apps look good but aren't accessible. :D
I've read this:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/TableViewOverview/TableViewOverview.html
up through designing the cell. They don't say where exactly to add custom views to my custom cell, though. They also say to use a subclass of NSTableCellView for custom cells, but I'm not clear on what that would do. Have outlets for the views in the cell, to be sure, but it wouldn't be part of the table view delegate. Oh… Wait, I'd use that subclass to make functions that set the different views in the cell, then call those functions from the table's delegate, wouldn't I? Makes sense, but I couldn't do that with bindings…
Well, I think that's plenty to start with, and if there are other tutorials, I'll read them. I wasn't able to find much on this topic, though. As always, thanks for your patience and help. It's really interesting coming at visual design and layout from a non-visual perspective. Fun times. :)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden