2012-12-02 34 views

回答

1

您需要運行if語句來檢查單元格的索引。 0是第一個索引,因此您需要檢查該行是否爲0.

- (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] autorelease]; 
     } 
     if (indexPath.row == 0) 
      cell.textLabel.text = @"First Cell"; 
     else 
      cell.textLabel.text = @"Not First Cell"; 
} 
0

爲了在單元格被創建/重用後訪問您的單元格,請嘗試使用您的uitableview對象的- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath方法!有關此方法的詳細說明,請參閱following Apple文檔。 注:

返回值

表示表或零的小區,如果小區是一個對象不 可見或indexPath超出範圍。

相關問題