非常奇怪的問題。我有一個自定義單元格的故事板UITableViewController。出於某種原因,單元格不顯示在我的TableView中。我把一些斷點和一些日誌消息,我可以告訴它獲取數據,我可以看到單元格有一個內存地址,所以它不是零。我只是不知道還有什麼要驗證的。UITableViewCell被分配但不顯示
由於某些原因,單元格的隱藏屬性被設置爲YES,所以我添加了cell.hidden = NO,但它仍然沒有出現。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier;
if(indexPath.section == 0) {
CellIdentifier = @"HeaderCell";
} else {
CellIdentifier = @"ConnectedGoalCell";
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if(indexPath.section == 0) {
//Section 0 Formatting.....displays OK
} else {
//This is the cell that doesn't appear in the tableView
UILabel * nameLabel = (UILabel*)[cell viewWithTag:10];
UILabel * dateLabel = (UILabel*)[cell viewWithTag:11];
NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone defaultTimeZone];
[formatter setDateFormat:@"MM/dd/yyyy"];
Goal * goal = [connectedGoals objectAtIndex:indexPath.row];
nameLabel.text = goal.name;
dateLabel.text = [formatter stringFromDate:goal.goal_date];
//Log said that cell HIDDEN was YES. Changed to no here but still no effect
//<UITableViewCell: 0xa288e30; frame = (0 389; 320 44); autoresize = W; layer = <CALayer: 0xa292a80>
cell.hidden = NO;
NSLog(@"CELL TYPE : %@ AT %@", indexPath, CellIdentifier);
//Logs:: CELL TYPE : <NSIndexPath 0xc3917d0> 2 indexes [1, 0] AT ConnectedGoalCell
NSLog(@"%@", cell);
//Logs:: CELL TYPE : <UITableViewCell: 0xc195ba0; frame = (0 389; 320 44); hidden = YES; autoresize = W; layer = <CALayer: 0xc171620>
}
return cell;
}
檢查您的'ConnectedGoalCell'的隱藏屬性。它正在隱藏。 – Ilanchezhian
更新了我的問題,謝謝。雖然顯然相關,似乎並沒有解決我的問題。 – ChickensDontClap