Tuesday, April 20, 2010

Custom Cells for Iphone Table View

Lets say you've added a nice new View XIB file, and thrown on a UITableView using the Interface Builder's Library tool.
And now you want to create a custom cell, how do you go about it? After scouring through several blogs and sites I couldn't quite figure out how to create just a custom cell:

I always ended up adding a new View XIB file, grabbing the UITableViewCell from the Interface Builder Library, dropping it in and getting this:

That's one massive cell and not very useful. So, this is how you really do it and its so simple you'll wonder why you didn't immediately get it yourself.
1. Add a new View XIB file, lets call it CustomCell.
2. In the Interface Builder in the window titled CustomCell.xib notice that by default a UIView has been added.
3. Select the UIView that was added by default and hit delete.
4. Now grab UITableViewCell from the Library and drop it into the CustomCell.xib window,
just like you would in the View Window.

5. Voila! You now have just a UITableViewCell and can customize it as you please.

Jake's blog post about SubViews and Table Views and the following reference cover how to implement the code to populate and handle these custom cells:
http://www.e-string.com/content/custom-uitableviewcells-interface-builder

2 comments:

  1. seiko titanium 3 piece design and construction | Tatanium Art
    The titanium 3 titanium septum ring piece titanium sheet metal design consists of a six-point wedge cut handle tungsten titanium (5-in-8 inches), with six a does titanium set off metal detectors design made microtouch trimmer from stainless steel, a titanium core, $39.99 · ‎In stock

    ReplyDelete