cellForRowAtIndexPath is not being called on iOS-tableView remains empty
I want to display the c开发者_运维问答ontents of an array in the tableView but the control never comes into cellForRowAtIndexPath. This method is where I add
cell.textLabel.text = [self.itemArray indexPath.row];
Please advise. how do you populate the table?
Are you sure it's not being called try putting a
NSLog(@"TEST")
see the output.That sounds a lot like the table view
datasource
being empty the first time sow you might want to check if the array has objects saved.Also you might want to check and see if
numberOfSectionsInTableView
table to be set at 1, andnumberOfRowsInSection
not equal 0. IfnumberOfRowsInSection
returns 0 then thecellForRowAtIndexPath
may not be called.
Have you implemented the other methods in UITableViewController:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.itemArray count];
}
If these return 0, then your cellForRowAtIndexPath method wont be called.
精彩评论