【发布时间】:2013-03-24 12:17:24
【问题描述】:
看到这篇文章,但没有解决我的问题。
iPhone app crashing on [self.tableView endUpdates]
拥有来自报纸网站的UITableView loads 文章。首先load 作品
正如预期的那样,但是当我再次使用UIRefreshControl 到fetch 文章时,我的应用程序崩溃了
当 (animating) inserting rows.
错误:
代码:
- (void)insertRowsWithAnimation
{
NSMutableArray *indexPaths = [NSMutableArray array];
NSInteger i = self.latestArticlesArray.count - self.latestArticlesArray.count;
for (NSDictionary *dict in self.latestArticlesArray) {
[indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
i++;
}
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];
[self.tableView endUpdates];
}
- (void)fetchEntries
{
UIView *currentTitleView = [[self navigationItem] titleView];
UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[[self navigationItem] setTitleView:aiView];
[aiView startAnimating];
void (^completionBlock) (NSArray *array, NSError *err) = ^(NSArray *array, NSError *err) {
if (!err) {
[[self navigationItem] setTitleView:currentTitleView];
self.latestArticlesArray = [NSArray array];
self.latestArticlesArray = array;
[self insertRowsWithAnimation];
}
};
[[Store sharedStore] fetchArticlesWithCompletion:completionBlock];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.latestArticlesArray.count;
}
如果您想查看更多方法,请告诉我。希望你能帮忙。从我到目前为止所了解到的情况来看,我认为帖子的数量已经改变,因此该表期望显示其他数量的文章?
【问题讨论】:
-
发布你的 numberOfRowsInSection: 方法。错误通常是因为您调用了 insertRow 但没有更改此方法中返回的行数
-
看我的帖子,我只是回馈
count,我是否必须在这个method中以某种方式刷新latesArticlesArray?
标签: iphone ios objective-c uitableview