我已經從NIB創建了一個自定義的UITableViewCell。當rowHeight沒有被設置時,所有東西都會出現(儘管一切都被壓扁了)。我不知道如果我再利用和妥善創建細胞:UITableViewCell不能正常顯示/從NIB中正確地重複使用
// 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;
}
問題:
- 不是當rowHeight時設置的所有標籤出現。如果沒有設置rowHeight時,標籤被壓扁
- 當rowHeight時未設置,選擇一個項目顯示了所有標籤的
問題仍然存在 – 2010-06-08 17:11:22