Ios insertRowsAtIndexPaths:首次加载时崩溃
它不是每次都发生,而是随机插入rowsatindexpaths:在tableviews EndUpdate上崩溃我的应用程序。这是代码Ios insertRowsAtIndexPaths:首次加载时崩溃,ios,uitableview,ios7,Ios,Uitableview,Ios7,它不是每次都发生,而是随机插入rowsatindexpaths:在tableviews EndUpdate上崩溃我的应用程序。这是代码 NSURLRequest *request1 = [NSURLRequest requestWithURL:url1]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request1 success:^(NSURLReque
NSURLRequest *request1 = [NSURLRequest requestWithURL:url1];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request1 success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
dispatch_async(dispatch_get_main_queue(), ^{
self.contentArray = [NSMutableArray arrayWithArray:JSON];
NSMutableArray *indexArray = [NSMutableArray array];
[self.contentArray enumerateObjectsUsingBlock:^(id anObject, NSUInteger idx, BOOL *stop) {
[indexArray addObject:[NSIndexPath indexPathForRow:idx inSection:0]];
}];
[self.mainTable beginUpdates];
[self.mainTable insertRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
[self.mainTable endUpdates];
self.mainTable.tableFooterView = [self buildLoadingView];
self.mainTable.contentInset = UIEdgeInsetsMake(64.0, 0.0, 80.0, 0.0);
});
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
NSLog(@"%@", JSON);
}];
[operation start];
非常感谢您的帮助!
提前谢谢 我认为您没有增加返回的行数,请确保在下面的方法中相应地增加和减少返回的行数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return numberOfRowsinTableSection;
}
我认为您没有增加返回的行数,请确保在下面的方法中相应地增加和减少返回的行数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return numberOfRowsinTableSection;
}
这是什么类型的崩溃,控制台是否提供了任何线索?您应该使用块说明符初始化*indexArray,例如:u block NSMutableArray*indexArray这是哪种崩溃,控制台是否提供了任何线索?您应该使用块说明符初始化*indexArray,例如:u block NSMutableArray*indexArray您是当今的英雄您是当今的英雄