UITableViewCell height with 0 rows

Posted by Typeoneerror on Stack Overflow See other posts from Stack Overflow or by Typeoneerror
Published on 2010-05-30T06:40:09Z Indexed on 2010/05/30 6:42 UTC
Read the original article Hit count: 173

Filed under:
|

I've got a moderately uncustomized UITableView in my application that presents an array of up to 6 peers for a networking game. When no peers are found the numberOfRowsInSection is 0, so when it loads up, there's no rows in the table:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 0;
} 

Trouble is, the height of each cell is not adjusted to match heightForRowAtIndexPath unless the numberOfRowsInSection is > 0. I hard-coded in "1" for this and the height is adjusted.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kTableRowHeight;
}

Can anyone tell me why this is? Will once the data that is being presented is longer than "0" length, will the height of the table cells jump to the correct height? I'd like them to be the correct height even if the row length is 0.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk