Objective c UITableView不需要的单元格
我的Objective c UITableView不需要的单元格,objective-c,Objective C,我的UITableView顶部有一个不需要的单元格。配置单元时,出于测试目的,我会执行以下操作: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueRe
UITableView
顶部有一个不需要的单元格。配置单元时,出于测试目的,我会执行以下操作:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
if (indexPath.row == 0)
{
cell.textLabel.text = @"LOL";
}
else {cell.textLabel.text = @"Hello";}
return cell;
}
我已将其设置为在1节中返回1个单元格。至于那些回来的细胞,我只看到一个写着“LOL”的,但是上面有一个看起来像空白细胞的
附图:
编辑:我通过删除整个表格视图并拖入一个新的表格视图来修复它。在这种情况下,我会标记单元格,例如,将单元格的背景颜色设置为绿色,这样就可以明显看出是否真的有多余的单元格,或者其他类型的空白。在安装表格单元格时,尝试设置“autorelease”:单元格=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier]autorelease];我正在使用ARC,所以我无法。在IB xib文件中,您是否碰巧在表视图的顶部放置了一个空白单元格?没有。它从一个原型单元格开始,但我删除了它。表大小一直拖到视图的顶部,然后由添加导航栏的navigationcontroller向下调整。