开发者

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?


  1. Are you sure it's not being called try putting a NSLog(@"TEST") see the output.

  2. 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.

  3. Also you might want to check and see if numberOfSectionsInTableView table to be set at 1, and numberOfRowsInSection not equal 0. If numberOfRowsInSection returns 0 then the cellForRowAtIndexPath 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜