【发布时间】:2012-05-02 15:09:46
【问题描述】:
我有一个 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;
}
错误:当我调用 [self.tableview 重新加载数据] 时,线程 1 sigabort 开启;
*** 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
【问题讨论】:
-
它在哪里崩溃?什么是崩溃报告?
-
您在帖子中说过,当您重新加载 tableView 时它会崩溃。首先是 [self.tableView reloadData] 而不是 [self.tableview reload data]。另外,你能粘贴你调用 reloadData 方法的地方吗?
标签: iphone objective-c uitableview nsarray