I have created a custom UITableViewCell from a NIB. Everything appears when the rowHeight is not set (albeit, everything is squished). I am not sure if I am reusing and creating the cells properly:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"ARCell";
ARObject *myARObject;
myARObject = [items objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"ARCell" owner:self options:nil];
cell = arCell;
self.arCell = nil;
}
UILabel *label;
label = (UILabel *)[cell viewWithTag:0];
label.text = [NSString stringWithFormat:@"%@", myARObject.username];
label = (UILabel *)[cell viewWithTag:1];
label.text = [NSString stringWithFormat:@"%@", myARObject.created_at];
label = (UILabel *)[cell viewWithTag:2];
label.text = [NSString stringWithFormat:@"%@", myARObject.articleTitle];
label = (UILabel *)[cell viewWithTag:3];
label.text = [NSString stringWithFormat:@"%@", myARObject.intro_text];
return cell;
}
- (CGFloat)tableView:(UITableView *)tblView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ CGFloat rowHeight = 105;
return rowHeight;
}
Problems:
- Not all labels appear when rowHeight is set. If rowHeight isn't set, labels are squished
- When rowHeight is not set, selecting an item shows all of the labels