2014-11-03 32 views
0

我有一個帶動態屬性內容和原型單元格數量爲1的UITableView; 段數= 16; 行數= 16; 是否可能像在第1節中只有第一行應該是可見的;在第2節中 - 只有第二行應該可見;在第3節中,只有第三行應該是可見的,依此類推?隱藏uitableview中的行 - iOS8

回答

1

如果你只是想在UITableView中「隱藏」一行,只需返回0代表其高度,而其他代碼不會隱藏。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (/* hide this specific cell */) { 
     return 0; 
    } 
    return regularCellHeight; 
} 

按照你說什麼,你的情況可能是:

indexPath.section != indexPath.row 
+0

它工作..thanx。:) – 2014-11-24 07:12:33

0

你應該通過你的數據源陣列管理你的所有內容不隱藏你的細胞。

如果你不得不改變(添加/刪除)某些特定的行而不重新加載整個表格,也許你應該看看這個方法。

[_tableView beginUpdates]; 
[_tableView deleteRowsAtIndexPaths:indexToRemove withRowAnimation:UITableViewRowAnimationAutomatic]; 
[_tableView insertRowsAtIndexPaths:indexToAdd withRowAnimation:UITableViewRowAnimationAutomatic]; 
[_tableView endUpdates];