【发布时间】:2014-04-29 02:17:19
【问题描述】:
在viewDidload中,tableview从服务器加载数据
success:^(NSArray *array) {
if (!_dataSource) {
_dataSource = [@[] mutableCopy];
}
if (array) {
[_dataSource addObjectsFromArray:array];
[_tableView reloadData];
}
}
然后每次我从底部拉起时,从服务器获取新数据并将其附加到 _dataSource(与第一次相同)
success:^(NSArray *array) {
if (!_dataSource) {
_dataSource = [@[] mutableCopy];
}
if (array) {
[_dataSource addObjectsFromArray:array];
[_tableView reloadData];
}
}
现在问题来了:有时从底部拉起,成功获取新数据,但是tableview不会立即显示新单元格,当我扫描tableview时(即使只是触摸屏幕)新的显示单元格。 可能是什么问题?
编辑
因为每个单元格的高度不一样,所以我没有重用单元格,每次都初始化一个新的单元格,是这个原因吗?
// TopicCell *cell = [tableView dequeueReusableCellWithIdentifier:TopicCellIdentifier];
// if(!cell){
// cell = [[TopicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TopicCellIdentifier];
// }
TopicCell *cell = [[TopicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TopicCellIdentifier];
@Jeffery Thomas,成功只是像这样的 AFNetworking 块
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:path
parameters:parameters
success:^(AFHTTPRequestOperation *operation1, id responseObject) {
}
failure:^(AFHTTPRequestOperation *operation2, NSError *error) {
}];
【问题讨论】:
-
你在 mainThread 中重新加载数据?
-
@nmh 当然
[_tableView reloadData];在主线程中。 -
如果您发布更多背景信息会很有帮助。包含
success:的方法是什么? -
@JefferyThomas 谢谢,请查看附加消息。
-
您的 AFNetworking 调用的上下文是什么?
scrollViewDidScroll:?
标签: ios objective-c uitableview