Can somebody point me to good sample code for creating custom UITableViewCells?
I've customized the cells created by the button views in the UICatalog application, but those are pretty simple-minded.
I need to pack a fair amount of information into a cell, and need fine control of placement and of the font sizes, etc.
I am writing an instant messaging application, and want to be able to display the message sender's nickname, the date and time of the message, and the message text. I'd like the user's name and the date/time to be on the left and right of a small bar at the top of the cell, and the message text to take up the majority of the rest of the cell. I will probably add an optional "avatar" icon on the left of the cell as an option at some point.
I also want the cell to get taller to fit longer messages. Yesterday somebody pointed me to a method, sizeWithFont:constrainedToSize:, that should let me calculate the height I need to display a given string at a specified font and size, and at a certain width, allowing for word wrapping. I think I can work that out.
At some point I may want to change the text in a message to use a web view, so I can display hyperlinks, and allow the user to click on them. I don't know how I'll size the view (and the cell) if I need to do that. Is there an equivalent call to sizeWithFont:constrainedToSize: for web views?
I'm thinking that I can brute-force lay out my different subviews in the cell, but I'm hoping there's an easier way.
I'm trying to get my tableView to be all black except for the text color. I believe this is the UI of the Shazaam App.
I've tried all the solutions on this forum and others, and it still doesn't work:
tableView.backgroundColor = [UIColor blackColor];
However, it works in the SQLite books example, so I think the problem is with my setup. In interface builder, my files go:
View Controller > MyView > TableView and the code above is in MyView.m file.
Any thoughts? I would like the background color of the table to be black, the cell background to be black, and the cell text to be white.
I would appreciate ANY help!
I'm guessing that you need to set the background color on your cells to black as well as setting the background color on the tableview's background to black. The cells normally cover the tableview.
I ended up pretty much copying word for word from the SQLite Books example.
I originally had: UIViewController > MyView > TableView.
I changed it to: MyViewController > TableView.
I think there was a problem with having an extra View which the table sat on top of, or it could have been the fact that I had a general UIViewController which was in charge of all my TabBar Views. So I made sure each TabBar View had its own _ViewController.
This is still pretty finicky, so if someone else understands it better, feel free to clarify....or reference this to another more appropriate thread.
THe best sample code for creating custom cells that I could find is from Erica Sadun's book (and for anyone to download here) cookbooksamples - Google Code
Chapter 6 09a "preferences table" - I could put alot of text in the custom cell but I couldn't figure out how to make it scroll (or not sure if that is even possible) - if you figure that out let me know