vgonisanz
vgonisanz

Reputation: 11930

Manage UITableView with custom UITableViewController created programmatically

I'm using XCODE 4.2 on iOS5.

I have created a UITableViewController custom, called picker. This is the class content:

NSMutableArray *_nameCollection;
NSMutableArray *_imageCollection;

With 2 elements each. That works well. If I create programmatically a UITableview, it shows the data correctly.

On the view, I declare the class (inside (void)viewDidLoad):

self.Picker = [[Picker alloc] initWithStyle:UITableViewStylePlain];
_Picker.delegate = self;
PickerTableViewIB = _Picker.tableView;   // Try to link using a IBOutlet

PickerTableViewIB is an Outlet from a Tableview, created inside a subview, using Interface Builder.

What is missing?

Upvotes: 4

Views: 192

Answers (1)

Igor N
Igor N

Reputation: 381

Are you setting the data source as well? You need that for the table view to get the data for populating. Otherwise the cellForRow method will not be called and your cells will not be populated.

_Picker.dataSource = self;

It would also be a good idea to call [self.Picker reloadData]; after setting the dataSource.

Upvotes: 1

Related Questions