나는이 오류를 완전히 조사해 왔으며 비슷한 문제가 있지만 해결할 수없는 몇 가지 게시물을 찾았습니다.정적 및 동적 UITableViewController 내용을 섞으면 NSRangeException이 발생합니다.
I는 섹션을 갖는다 (SB 정적으로 선언)가있는 UITableViewController 가지고 제 0 (레시피)을 104 개 세포와 정적 인, 제 1 단계 (풍미) 이것은
동적이어야
- (void)viewDidLoad {
[super viewDidLoad];
rows = [[NSMutableArray alloc] initWithArray:@[@"test",@"test",@"test",@"test",@"test",@"test",@"test"]];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
switch (section) {
case 0:
return 4;
break;
case 1:
return rows.count;
break;
default:
break;
}
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
switch (indexPath.section) {
case 0:
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
break;
case 1:
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell)
{
// create a cell
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.textLabel.text = [rows objectAtIndex:indexPath.row];
return cell;
default:
break;
}
return cell;
}
이제 실행할 때 내가지고있어 오류는 다음과 같습니다 : 'NSRangeException', 이유 : 나는 시험에 사용하고 코드 '*** - [__ NSArrayI objectAtIndex :] : 인덱스 1 범위를 넘는 [0 .. 0] '
나는 작은 어딘가에 뭔가를 놓친다는 것을 알고 있는데, 누군가 나를 도울 수 있습니까? 나는이 오류가 발생하는 이유를 발견 같은
내가 당신의 링크에 도움이되는 방법이 표시되지 않습니다이 http://stackoverflow.com/a/9428324/285190 – Flexicoder
에서 살펴 이 문제는 거기에 설명 된 문제가 내 것과 같지 않다는 것을 제외하고는 UITableViewController와 UIViewController를 사용하지 않고 – CRE8IT
numberOfRowsInSection 직후에 충돌이 발생하고 CellForRowAtIndexPath에도 적용되지 않는다. – CRE8IT