I’ve used the following code in a normal UIViewController with some other contents, the table view is on the bottom part of the view:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [names count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"namen";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
NSString *cellValue = [names objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
And a NSMutableArray called names (with 4 objects)
This code doesn’t work with a UITableViewController, either… You’ll need to create your table view cell in
-tableView:cellForRowAtIndexPath:. When you dequeue cells, the return value might be nil, if there are no cells that can be dequeued.