I have a UITableView in my nib file and would like to dynamically add some content to each of the cells in that TableView. Is there a way to do this? I have an array of text that I would like to display in the TableView as well as an array of Pictures.
I have a UITableView in my nib file and would like to dynamically add
Share
You need to implement the
UITableViewDataSourceprotocol and override theand
methods. You will want to return the length of your array for the
tableView:numberOfRowsInSection:method. In thetableView:cellForRowAtIndexPath:method you will get create theUITableViewCell(dequeue one if available) and add theUIViews you want to hold your data (i.e. a UIImage, etc.). Access the data to populate your view using the indexPath.row as the index to your array(s). Does that all make sense? It sounds a bit more complicated than it is in practice.Here is the documentation for the UITableViewDataSource protocol