选择行时我遇到了这个崩溃:' - [__ NSCFArray objectAtIndex:]:index(1)超出bounds(1)',
我将数据移出viewWillAppear,因为我们虽然导致了崩溃。我现在在ViewDidLoad上加载它。
但是如果[self.tableview reloadData];是的,我得到了这个崩溃。
想法?
-(void) loadData3;{
MyAppDelegate *AppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource3 = [AppDelegate.data3 objectForKey:@"Rows"];
NSLog(@"AppDelegate.data3 : %@",AppDelegate.data3 );
NSLog(@"self.tableDataSource3 : %@",self.tableDataSource3 );
}
- (void)viewDidLoad {
[super viewDidLoad];
[self loadData3];
if(CurrentLevel3 == 0) {
self.navigationItem.title = @"Families I Follow";
}
else
self.navigationItem.title = CurrentTitle3;
}
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear: animated];
[self.tableview reloadData];
}
答案 0 :(得分:1)
很可能,您正在更改在显示UITableView时加载UITableView的Array,因此当您单击Row时,Array中的行不再存在。因此,Array上的越界错误。
答案 1 :(得分:1)
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView reloadData];
}
将reloadData
移至viewDidAppear
可以解决此问题。
答案 2 :(得分:0)
由于选择行时发生错误,因此错误最有可能出现在tableView:didSelectRowAtIndexPath:
或tableView:willSelectRowAtIndexPath:
方法中。您发布的viewWillAppear:
代码片段似乎没有任何内在错误。