我创建了一个可编辑的 UITableView,它支持我自己设计的几个自定义 UITableViewCell。每当用户创建新记录或修改现有记录时,他们都会使用此 UITableView。我使用分组样式表视图将表视图分成几组 tableViewCells。
当用户正在编辑记录时,我不希望显示第 1 部分。为了实现这一点,我在调用 numberOfRowsInSection 方法时返回 0。一切正常,但是第 0 部分和第 2 部分之间存在“轻微的视觉差距”,如果可能的话,我想消除它。我想避免重新编码表视图控制器来动态处理 indexPaths。我的许多 indexPaths(部分和行)都是硬编码的。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
printf("CustomEntryViewController, -tableView:numberOfRowsInSection:\n");
if (tableView == self.customEntryTableView) {
if (section == 0)
return 1;
else if (section == 1) {
if ([self.entryMode isEqualToString:@"ADD"])
return 2;
else if ([self.entryMode isEqualToString:@"EDIT"])
return 0;
}
else if (section == 2)
return 1;
else if (section == 3)
return 1;
else if (section == 4 && self.uisegQuantityAnswer.selectedSegmentIndex == 0)
return 1;
}
return 0;
}
提前致谢。