1
셀을 재사용하면서 레이블을 UITableViewCell에 추가 할 수 있습니까? 이것은 내가 시도한 코드이지만 아래로 스크롤하면 셀이 재사용됩니다. 나는 항상 첫 줄에 레이블을 넣고 싶지만, 내 인생에 대해 이것을 알 수는 없다. 나는 세포를 재사용 할 수 없다는 것을 알고 그것은 효과가 있지만 세포를 재사용하고 싶다. 이 점을 이해하도록 도와주세요. 대단히 감사합니다 ...셀을 재사용하면서 첫 번째 UITableViewCell 행에 레이블 추가
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
}
if ([indexPath row] == 0) {
UILabel* Label = [[UILabel alloc] initWithFrame:CGRectMake(2,2, 62, 23)];
[Label setText:@"Text"];
[cell addSubview:Label];
[Label release];
}
return cell;
}