2011-11-03 45 views
0

我收到了一個不需要的單元格,位於我的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」的細胞,但看起來像上面的空白細胞。

圖片附:

Table View

編輯:我通過刪除整個表視圖和拖動在一個新的固定它

+0

當您的表格單元格安裝時,嘗試設置'autorelease': cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; – Maggie

+0

我正在使用ARC,因此我無法使用。 – Baub

+0

在你的IB xib文件中,你碰巧在表格視圖的頂部放置了一個空白單元格嗎? – Colin

回答

1

在這些種類的情況下,我將標誌着例如,將單元格的背景顏色設置爲綠色,因此它是否真的存在額外的單元格或某種其他類型的空白變得明顯。

+0

剛剛嘗試過,它隻影響「LOL」 – Baub

+0

表格大小一直拖到視圖頂部,然後由添加NavBar的navigationcontroller向下調整。 – Baub