我收到了一個不需要的單元格,位於我的UITableView
的頂部。當我配置單元,用於測試目的,我做到以下幾點: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': cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; – Maggie
我正在使用ARC,因此我無法使用。 – Baub
在你的IB xib文件中,你碰巧在表格視圖的頂部放置了一個空白單元格嗎? – Colin