我有用于 youtube 电影的简单 UITableView。单元格从数组加载,当我从 youtube API 获取前 10 部电影时,最后一个单元格是“加载更多”单元格。当用户点击“加载更多”单元格时,它将获取并加载接下来的 10 部电影。一切都很好,除非我在“负载单元”上快速点击两次或更多次,然后它会用新数组刷新我的表格,而不是我有奇怪的行为(所有单元格的电影都消失了,我有很多“负载更多”单元格分布在表格行中)所以我的表格完全乱了。如果我轻按一下“加载更多”单元格,则不存在问题。
在点击我的单元格后,我已将 userInteractionEnabled 设置为 NO,但它没有帮助。有人可以告诉我我做错了什么吗?这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Load more json data if loadmore cell tapped
if (indexPath.row == self.videos.count) {
self.loadCell.userInteractionEnabled = NO;
self.loadCell.title.text = @"loading...";
//Activity indicators for loadmore cell
[self.loadCell.loadMoreActivityIndicator startAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[self performSelectorInBackground:@selector(youtubeFeedMore) withObject:nil];
}
}