У меня есть табличное представление. Он получит беспорядок данных с сервера. Каждый раз, когда tableview получает данные, я хочу, чтобы он показывал последний снизу. Я назвал scrollToRowAtIndexPath:atScrollPosition:animated:
, но он отстает от моего приложения. Я ничего не могу сделать на своем экране, когда прокручиваюсь до нижней части таблицы. Вот мой основной кодUITableView scrollToRowAtIndexPath: atScrollPosition: анимированный: сильно отстает от моего приложения
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"tableViewCell";
DLtestCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
NSDictionary* dict = arr[indexPath.row];
cell.myLabel.attributedText = dict[@"content"];
[cell.myImageview sd_setImageWithURL:dict[@"imageUrl"] placeholderImage:[UIImage imageNamed:@"transparentPlaceHolder"]];
return cell;
}
и здесь дрейфует к нижнему основному коду
- (void)reloadTableView
{
dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath *lastRow = [NSIndexPath indexPathForRow:row inSection:0];
[self.tableView insertRowsAtIndexPaths:@[lastRow] withRowAnimation:UITableViewRowAnimationLeft];
});
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
попробуйте перезагрузить в основном потоке (выполнитьOnMainThread) метод – SM18