当所有部分和行都在 nib 中静态定义时,是否可以在运行时从 UITableView
中删除行?
在下面的 Storyboard场景中,我可以在运行时删除“Addr 2”字段吗?在这种情况下,我没有向 UITableView
提供数据源。
我不知道“删除”,但您可以使用 tableView:heightForRowAtIndexPath:
隐藏该行。
- (void)methodToToggleAddr2CellVisibility
{
self.addr2CellIsHidden = !self.addr2CellIsHidden;
[self.tableView beginUpdates];
[self.tableView endUpdates];
}
- (float)tableViewUITableView *)tableView heightForRowAtIndexPathNSIndexPath *)indexPath
{
if (indexPath.section == 1 && indexPath.row == 1) { // the cell you want to hide
if (self.addr2CellIsHidden == YES) {
return 0;
} else {
return 44;
}
}
return 44;
}
关于ios - 在运行时从静态 UITableView 中删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19941813/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) | Powered by Discuz! X3.4 |