Namratha
Namratha

Reputation: 16790

cellForRowAtIndexPath is not being called on iOS-tableView remains empty

I want to display the contents 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?

Upvotes: 1

Views: 8402

Answers (2)

Radu
Radu

Reputation: 3494

  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.

Upvotes: 16

npellow
npellow

Reputation: 1985

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.

Upvotes: 3

Related Questions