gpt4 book ai didi

ios - insertRowsAtIndexPaths : crashes on first load

转载 作者:行者123 更新时间:2023-11-29 13:04:46 24 4
gpt4 key购买 nike

它不会每次都发生,但会随机 insertRowsAtIndexPaths: 使我的应用程序在 tableviews endUpdates 上崩溃。这是代码。

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;

}

关于ios - insertRowsAtIndexPaths : crashes on first load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18907746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com