Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Interface Builder for UITableViews

I'm very early in the iPhone development learning process. I'm trying to get my head around various pieces. Right now I've just taken the basic NavigationController template and I'm trying to create a simple grouped table view with a couple of text fields. What I can't seem to do is to get Interface Builder to allow me to drop a UITableViewCell into a UITableView so that I can then add a text field to the Cell. Is this even possible (it would seem that its supposed to be given the fact that UITableViewCell is a draggable control)?

If not, does that mean all of that is code I will need to just write myself?

like image 609
flxkid Avatar asked Sep 25 '08 17:09

flxkid


People also ask

What is difference between TableView and Collectionview?

Table view presents data in multiple rows arranged in a single column, the cell design is fit as a row. However, collection view can create rows and columns, it can design cells in various ways, even if they are not necessarily rows. It's also the biggest feature of a collection view cell.


1 Answers

You can create the cell with Interface Builder, but you have to make it a top-level object, rather than a child of the table view. Then you can return this cell in your view controller's tableView:cellForRowAtIndexPath: function.

Make sure to give the cell an identifier in Interface Builder and then use the same identifier with dequeueReusableCellWithIdentifier: (see the sample code for how this works -- the idea is that cells get re-used - the OS will only allocate as many cells as fit on the screen at once. Clever way to save memory.)

like image 84
Chris Lundie Avatar answered Sep 18 '22 03:09

Chris Lundie