views:

54

answers:

1

What I've done is created a custom TableCell view that gets populated with information from an array of objects. Each TableCell gets loaded in the

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

     static NSString *CellIdentifier = @"CellIdentifier";

     Cell *cell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

     if (cell == nil) {
         NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Cell" owner:self options:nil];
         cell = [nib objectAtIndex:0];
     }

     NSUInteger row = [indexPath row];
     NSDictionary *rowData = (NSDictionary *)[self.surveys objectAtIndex:row];

     cell.info1.text = [rowData objectForKey:@"info1"]; 
     cell.info2.text = [rowData objectForKey:@"info2"]; 
     cell.info3.text = [rowData objectForKey:@"info3"];
     cell.otherInfo = [rowData objectForKey:@"otherInfo"];

     return cell;
}

In addition to this I specify a custom height for the cell here

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

When the value for tableView: heightForRowAtIndexPath: is 76 it loads all the cells that I can see and they aren't ever blank. Without changing anything else in the code I can modify the value in tableView: heightForRowAtIndexPath: and it will only show the first cell value when the view is loaded. As I scroll down they are refreshed with a value as soon as their top edge hits the top of the screen. When I get back up to the top and stretch the view so that it bounces back the bottom ones will disappear.

As far as I can tell, the change in height somehow affects how they are loaded but I can't for the life of me see how.

A: 

I specified a height in the custom cell .xib that was different than the one I was specifying in code. Once this was changed to match the size specified in the code the problem went away.

mwright