记住UITableView上的滚动位置 [英] Remembering scroll position on UITableView

查看:114
本文介绍了记住UITableView上的滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在xcode中的iOS应用程序有点问题。我有一个UITableView加载几百个单元格。当我向下滚动到特定单元格并向下钻取到detailviewcontrollers并再次返回时,主视图表一直返回到顶部。我已经看了下面两个相似的问题。

I have a bit of a problem with my iOS app in xcode. I have a UITableView that loads a few hundred cells. When I scroll down to a specific cell and drill down to detailedviewcontrollers and return again the master view table has returned all the way to the top. I've had a look at the following 2 questions that are similar.

如何获得UITableView滚动位置,以便保存?

在UITableView中设置滚动位置

我仍然无法让这些工作。我不是最有经验的编码器,所以我真的很挣扎。

I still can't get these to work. I'm not the most experienced coder so I'm really struggling with this.

我知道像viewWillDisappear和viewDidAppear这样的东西需要改变,但我真的可以'比这更进一步。

I know things like viewWillDisappear and viewDidAppear need to be changed, but I just really can't get much further than that.

在这个表上,我有一个reloadData功能,因此可以从服务器和工作搜索栏中下载最新数据。

On this table I have a reloadData feature so it is possible to pull down the latest data from the server and also a working search bar.

无论如何,伸出援助之手会很棒。谢谢,

Anyway, a helping hand would be great. Thanks,

卢克

推荐答案

排序!

从Desdenova那里得到一些灵感,在工作中我很好地思考它并意识到它可能是什么。记住我有一个搜索栏,几个月前我已经实现了以下代码来隐藏它:

With a bit of inspiration from Desdenova, whilst at work I had a good think about it and realised what it could be. Remembering that I had a search bar, I had implemented the following code a few months ago to hide it:

[self.tableView setContentOffset:CGPointMake(0,-20) animated:NO];

天真地我把它放在 viewDidAppear 中比 viewDidLoad 。显然,这确实隐藏了搜索栏,但是当它在错误的void命令中时,它每次masterDetailView返回到堆栈顶部时都会执行它。所以,在将上面的代码移到viewDidLoad之后,它现在仍然隐藏它,但只有一次。

In naivety I put that in viewDidAppear rather than viewDidLoad. Obviously, this did hide the search bar, but with it being in the wrong void command it did it every time the masterDetailView returned to the top of the stack. So, after moving the above code to viewDidLoad it now still hides it, but only the once.

我只是像其他初学者一样拼出来,比如我自己,谁可能会遇到同样的问题,可能只是为了节省他们的理智!

I'm just spelling it out like this for other beginners, like myself, who may come across the same problem and may just save their sanity!

感谢大家帮助我的所有想法。

Thanks to you all for your ideas that helped me out.

+1给你们所有人!

这篇关于记住UITableView上的滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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