Change UITableViewCell from UIViewController with UITableView out on iPhone

Here is the situation

I have a UIViewController class with a UITableView output. I would like to change / style a cell. I believe I can do this with the UITableViewCells tableviewCellWithReuseIdentifier method. Since my class is not a UITableViewController it doesn't have this method. How can I use this method from UIViewController class.

Also I know I can create my own UITableViewCell class and create it instead of the regular UITableViewCell class, but anyway, what can I do in the UIViewController class?

Thanks Joe

0


a source to share


1 answer


A UITableViewController - is, in fact, the UIViewController with a copy of the UITableView, and he is set to viewController delegate

and dataSource

for a table (which implies that viewController implements stub for these delegate methods).

You can do this yourself by implementing the UIViewController protocols UITableViewDataSource

and UITableViewDelegate

. Then in the UIViewController loadView

(or viewDidLoad

) method, set the tableView instance dataSource

and delegate

in self

.



To return a custom cell, your UIViewController implements a method cellForRowAtIndexPath

and returns a custom cell.

Also, have a look at Matt Gallagher's post on ways to customize a table cell without subclassing UITableViewCell: http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

0


a source







All Articles