2013-05-17 12 views

回答

1

起初,爲什麼你不重用細胞?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    Cell* cell = [tableView dequeueReusableCellWithIdentifier:cell_id]; 
    if(!cell) 
    { 
     cell = // create new cell; 
    } 

    // configure cell 

    return cell; 
} 

併爲您的問題:似乎initWithData:已經返回一個自動釋放的對象,那麼你再派自動釋放。因此請檢查該方法以找出問題。

0

對於創建自定義的UITableViewCell的,編寫代碼以這種方式:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     static NSString *CellIdentifier = @"MyTableViewCellId"; 
     MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     if (cell == nil) { 
      NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MyTableViewCell" owner:self options:nil]; 
     cell = [topLevelObjects objectAtIndex:0];  
     } 

     // write your code to customize cell or providing data content 

     return cell; 
} 

希望這將幫助你解決你的問題

相關問題