当行大于1时,我有一个uitableview崩溃。这完全没有意义,因为它们是数组中的两个对象。它适用于对象一,但不是两个。检查出:当行数大于1时,UITableView崩溃
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"rigth not %i", [pro.matches count]);
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//NSLog(@"%i", indexPath.row);
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// configure your cell here...
if ([pro.matches count] >0) {
cell.textLabel.text = [pro.matches objectAtIndex:1];
}
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;
}
错误:线程1 sigabort当我打电话[self.tableview重载数据];
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x13dc022 0x156dcd6 0x13c8644 0x44cea5 0x2591a8 0x204688 0x206862 0xb466d 0xb4167 0x2a42 0x9a5f 0xa2755e 0x96463e 0x95d1e7 0x95ceea 0x9ed0ad 0x3da2330 0x3da4509 0x1313803 0x1312d84 0x1312c9b 0x12c57d8 0x12c588a 0x26626 0x20ed 0x2055)
terminate called throwing an exception
它在哪里崩溃?什么是崩溃报告? – jrturton
你在你的文章中说过,当你重新加载tableView时它崩溃了。首先它是[self.tableView reloadData]而不是[self.tableview重载数据]。另外,你可以粘贴你调用reloadData方法的地方。 – azamsharp