PDA

View Full Version : Difference between a cell and a row in Tableviews?




animefx
Aug 7, 2012, 12:13 PM
I'm about ready to tackle tableviews but I'm a little confused about the difference between cells and rows. They seem like the same thing to me, but obviously they are not the same. All of the material I've been reading kind of takes for granted that you know the difference.



dejo
Aug 7, 2012, 12:42 PM
In the world of Cocoa Touch / UIKit, a row can only contain one cell, so, effectively, they can be thought of as the same thing. The reason that somewhat of a differentiation is made, I feel, is because Cocoa Touch was born of Cocoa, where each row can contain multiple cells (i.e. columns).

animefx
Aug 7, 2012, 01:56 PM
I see, I guess that makes sense. My only confusion now is what to do when a method wants a parameter for both a cell and row... Which one do I address?

In the world of Cocoa Touch / UIKit, a row can only contain one cell, so, effectively, they can be thought of as the same thing. The reason that somewhat of a differentiation is made, I feel, is because Cocoa Touch was born of Cocoa, where each row can contain multiple cells (i.e. columns).

TheWatchfulOne
Aug 7, 2012, 02:27 PM
The big difference I can see between a row and a cell is that a UITableViewCell is an object in and of itself. Apple provides 4 pre-made styles that you can choose from. You can look in the default Contacts; Music; and Settings apps to see what they look like. Apple provides documentation to explain which is which. If none of the pre-made cells are what you're looking for, then you can build a custom cell that fits your needs exactly.

A "row" is not necessarily an object unto itself but rather an element (or subview, rather) of a UITableView object. The UITableViewDelegate has methods that you implement to determine how many rows the table view will contain. After that there is a method you must implement that will return a UIITableViewCell for each row. As Deja said, each row gets one table view cell.

That's a very basic overview. Any book or tutorial you go through will explain things in greater detail. Feel free to come back with questions.

I've heard it said UITableViews are one of the most difficult views implement really well. I say they are one of the most worthwhile ones to learn really well because they are used in so many apps.

So, don't get discouraged OK?:cool:

dejo
Aug 7, 2012, 02:35 PM
My only confusion now is what to do when a method wants a parameter for both a cell and row...

For example?