调用-reloadData后如何保持UITableView contentoffset [英] How to keep UITableView contentoffset after calling -reloadData

查看:38
本文介绍了调用-reloadData后如何保持UITableView contentoffset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CGPoint offset = [_table contentOffset];
[_table reloadData];
[_table setContentOffset:offset animated:NO];    //unuseful

//    __block UITableView *tableBlock = _table;
//    [self performBlock:^(id sender) {
//        [tableBlock setContentOffset:offset];
//    } afterDelay:2];

我不知道在 reloadData 之后调用的任何委托方法.并且使用 afterDelay:2 这是一种黑客可能太短或太长,那么我该如何实现呢?

I know don't know of any delegate method which gets called after reloadData. And using afterDelay:2 which is kind of a hack may be too short or too long, so how can I implement it?

推荐答案

我最近在使用 reloadData -- reloadData 不会改变 contentOffset 或滚动表格视图.如果偏移量小于新的数据量,它实际上保持不变.

I was recently working with reloadData -- reloadData doesn't change the contentOffset or scroll the table view. It actually stays the same if the offset is less than the new amount of data.

这篇关于调用-reloadData后如何保持UITableView contentoffset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆