我不确定现在问这个问题是否合适。我在表视图上使用Xcode 5(预览版)。现在的问题是如果我的表格视图被选为group
而不是我在第一个单元格和表格的上边缘之间有间隙。
uitable视图委托的代码位于
之下- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 8;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"cell %d",indexPath.row];
return cell;
}
我在xib中选择group
时的图片
但是,如果我切换到plain
,表格是正常的
对这种情况有任何想法。我用Google搜索,但似乎没有任何东西。欢迎任何帮助。
答案 0 :(得分:19)
这是iOS 7中分组表视图的预期外观。如果打开“设置”应用,您将在表格顶部和表格视图中的每个部分之间看到类似的分隔条(灰色)
答案 1 :(得分:1)
为了彻底,你应该在表格视图中实现部分的数量,在这种情况下,返回一个部分。它可能是Xcode 5中的一个错误,如果你没有实现该方法,它会为你提供一个不正确的标题。
如果这不能解决问题我建议实施
- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section
这也可以解决问题。