4 개의 섹션이있는 기본 UITableView가 있습니다. Switch 문을 사용하여 각 섹션의 내용을 제어합니다.IOS : 셀을 UITableView에서 잘못 재사용 중지
첫 번째 섹션의 행에 나타나야하지만 네 번째 섹션에는 나타나지 않아야하는 버튼을 프로그래밍 방식으로 만듭니다. 그러나 버튼은 네 번째 섹션의 행에 무작위로 나타납니다.
셀 재사용 때문입니다. 그러나 Switch 문을 사용하여 각 섹션의 행을 만들 때 어떻게되는지 알 수 없습니다. 어떤 아이디어라도 감사합니다.
내가 그렇게 구성된 사용자 정의 셀을 사용하고 있습니다 :`
static NSString *CustomCellIdentifier = @"DashboardCell";
DashboardCell *cell = (DashboardCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DashboardCell"
owner:self options:nil];
for (id oneObject in nib) if ([oneObject isKindOfClass:[DashboardCell class]])
cell = (DashboardCell *)oneObject;
}
// Configure the cell.`
이 버튼을 작성하는 코드 것은`
button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(200, 11, 50, 50);
UIImage *iConnect = [UIImage imageNamed:@"connect.png"];
[button setImage:iConnect forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonSelected:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:button];`
감사합니다. Barjavel. 두 가지 세포 유형을 만들었습니다. 매력처럼 작동합니다. – Jeremy