2012-12-02 3 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 범위를 벗어났습니다.

관련 문제