iOS 7/8 애플리케이션이 있습니다. 보기에서 나는 주어진 수의 셀이있는 정적 인 UITableView를 가지고있다 - 나의 경우에는 17이다.
셀 중 하나에 동적 셀이 포함 된 다른 UITableView가 포함되어 있습니다. 경우가 있기 때문에 셀의 수 (+3) I는UITableView의 중첩 된 UITableView로 인해 iOS에서 바운드 된 인덱스가있는 NsRangeException이 발생합니다.
NSRangeException 얻을 차이 20.
이다 기재된 '이유'*** - [__ NSArrayI objectAtIndex :] 인덱스 (17)를 넘어 bounds [0 .. 16]
동적 뷰에서 18 번째 셀을 설정할 때 예외.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == _dynamicTableView) {
NSLog(@"%lu", (unsigned long)[[_filter types] count]);
return [[_filter types] count];
} else {
return 17;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == _dynamicTableView) {
static NSString *cellIdentifier = @"type";
TypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[TypeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
}
NSArray *types = [_filter types];
Type *type = [types objectAtIndex:[indexPath row]];
[cell.nameLabel setText:[type name]];
return cell;
} else {
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}
}
스토리 보드에 가서 정적 셀의 수를 30 개로 늘리면 모두 정상적으로 작동합니다. tableView : numberOfRowsInSection ... 메서드는 사용되지 않는 셀을 제거합니다. 17 개의 정적 셀과 20 개의 동적 셀만 표시됩니다.
나는 하나의 컨트롤러에 두 개의 UITableView-s와 많은 양의 'if'-s가있는 문제의 원인을 알고있다.
수퍼 클래스에 코드를 게시 할 수 있습니까? '[super tableView : tableView cellForRowAtIndexPath : indexPath]'?? – GoodSp33d
그것은 UITableView 기본 방법입니다. 저는 제 3의 계급을 물려받지 않습니다. –