첨부 된 세그먼트 화 된 제어 값을 기반으로 제공된 두 개의 데이터 세트 중 하나를 사용하여 내용이 채워진 테이블이 있습니다. 데이터는 웹에서 가져옵니다.세그먼트 화 된 UITable의 불안정
두 데이터 집합간에 앞뒤로 이동 한 다음 표 셀을 선택하면 응용 프로그램이 충돌합니다. 분할 된 컨트롤이있는 단일 테이블이 아닌 두 개의 개별 테이블을 사용할 때 딸꾹질없이 응용 프로그램이 작동합니다. 어떻게 든 그들을 결합하면 응용 프로그램이 불안정 해집니다.
가장 큰 오류 중 하나는 내가 Acells of A 테이블을 탭했을 때로드가 세그먼트 인덱스 = 1을 두드리는 동안 B가로드되어 인식 할 수없는 선택기가 전송됩니다. 매개 변수의 의미 o B 테이블로 보내지는 테이블.
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier0;
if (choice == 0) {
CellIdentifier0 = @"ACell";
} else if (choice == 1) {
CellIdentifier0 = @"BCell";
}
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (cell == nil) {
if (choice == 0) {
[[NSBundle mainBundle] loadNibNamed:@"ACell" owner:self options:nil];
cell = ACell;
self.ACell = nil;
} else if (choice == 1) {
[[NSBundle mainBundle] loadNibNamed:@"BCell" owner:self options:nil];
cell = BCell;
self.BCell = nil;
}
}
if (choice == 0) {
[(ACell *)cell setA:(A*)[contentArray objectAtIndex:indexPath.row]];
} else if (choice == 1) {
[(BCell *)cell setB:(B*)[contentArray objectAtIndex:indexPath.row]];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (choice == 0) {
A = [contentArray objectAtIndex:indexPath.row];
[[NSNotificationCenter defaultCenter] postNotificationName:@"showA" object:A];
} else if (choice ==1) {
B = [contentArray objectAtIndex:indexPath.row];
[[NSNotificationCenter defaultCenter] postNotificationName:@"showB" object:B];
}
}
이것은 셀을 재사용 할 때 문제가 될 수 있습니다. ** 코드 ** 없이는 말할 길이 없습니다. – PengOne
보유 코드가 도움이되지 않는 – lilzz