I\'m trying to make use of the new Storyboard designer and the ease of drawing UITableView cells instead of programmatically \"designing\" each row.
A good example of a
There are two ways you can get to your custom subviews. The simpler way is using tags. Every view has a tag
property which is an integer. You can set the tag in the nib, and set or get it in code. You can search a view tree for a view with a given tag by sending viewWithTag:
to the root of the tree. So, for example, you could give your labelTime
view the tag 57, and in your code, you'd find the view like this:
UILabel *label = (UILabel *)[cell viewWithTag:57];
The downside of using tags is that you have to keep the tag numbers in sync between your nib and your code. If they get out of sync, you'll either get the wrong view back or you'll get nil (and since you can send messages to nil, the system won't give you an error when that happens). Still, tags are so convenient that it's pretty common to use them like this.
The other way is to create a custom subclass of UITableViewCell
with an IBOutlet
property for each custom subview. You can hook up the outlets to the subviews in the nib, and access the subviews via the properties in your code:
MyTableViewCell *myCell = (MyTableViewCell *)cell;
UILabel *label = cell.labelTime;
This entails writing a lot more boilerplate than using tags, but it has the advantage that you will get warnings or errors (either at compile-time or when you first try to load the nib) if your nib and your code get out of sync.