2014-04-05 26 views
0

此行爲僅在iOS 7.0上,在7.0上它按預期工作。UITableView - 有時在7.1上展開單元格時滾動,而不是7.0

我有一個UITableView與不同高度的單元格。當其中一人拍打,它通過

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (indexPath.row != self.selectedCellIndexPath.row) { 
     // Close previously opened cell 
     if (self.selectedCellIndexPath != nil) { 
      [tableView beginUpdates]; 
      [(MyTableViewCell *) [tableView cellForRowAtIndexPath:self.selectedCellIndexPath] collapse]; 
      [tableView endUpdates]; 
     } 

     self.selectedCellIndexPath = indexPath; 

     [tableView beginUpdates]; 
     [(MyTableViewCell *) [tableView cellForRowAtIndexPath:indexPath] expand]; 
     [tableView endUpdates]; 
    } 
    else if (indexPath.row == self.selectedCellIndexPath.row) { 
     self.selectedCellIndexPath = nil; 
     [tableView beginUpdates]; 
     [(MyTableViewCell *) [tableView cellForRowAtIndexPath:indexPath] collapse]; 
     [tableView endUpdates]; 
    } 
} 

擴展當在的tableView的頂部上連續敲擊,一切都表現爲預期 - 單元格向下擴展,電池的頂部停留在哪裏。但是當向下滾動並在桌面視圖的底部單擊更多單元格時,單元格會向下移動並展開。細胞越遠,情況越糟糕。

我計算表格單元格高度是這樣的:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    self.prototypeCell = [[MyTableCell alloc] initReuseIdentifier:CellIdentifier]; 
    [self configureCell:self.prototypeCell forIndexPath:indexPath]; 

    float height = 38; 
    if ([indexPath isEqual:self.selectedCellIndexPath]) { 
     height += [self.prototypeCell expandedHeight] + 5; 
    } 

    return height; 
} 

我惱火,如果我在頂部或在的tableView的底部在電池接頭的效果是不同的。而且,這種效果只是在向下滾動後第一次。按照預期,重複時,細胞停留在其位置。只有在上下滾動之後,它纔會在第一次出現錯誤。

回答

1

我解決了這個問題;這是由於estimatedHeightForRowAtIndexPath,我刪除了該方法,現在擴展/摺疊按預期工作。

+0

幫助我,謝謝你能解釋理由,如果你知道 –

相關問題