通过点击状态栏滚动到 UITableView 的顶部 [英] Scroll to top of UITableView by tapping status bar
问题描述
我知道有大量代码可以将 tableview 滚动到顶部,但是我想在点击顶部状态栏时执行此操作,就像在 Apple 的本机应用程序中一样.这可能吗?
I know there's tons of code out there to scroll a tableview to the top, but I want to do this when the top status bar is tapped, just like in Apple's native apps. Is this possible?
推荐答案
你可以免费获得这个,但是你应该检查你的 UITableView
的 scrollsToTop
属性是否为 YES.
You get this for free, but you should check that the scrollsToTop
attribute of your UITableView
is YES.
当这不起作用是当你有一个 UIScrollView
(或像 UITextView 这样的后代类)对象嵌入另一个 UIScrollView
类(如 UITableView
>).在这种情况下,将嵌入的 UIScrollView
类上的 scrollsToTop
设置为 NO.然后点击状态栏行为将起作用.
When this does NOT work is when you have a UIScrollView
(or descendant class like UITextView) object embedded inside another UIScrollView
class (like UITableView
). In this case, set scrollsToTop
on the embedded UIScrollView
class to NO. Then the tap-the-status-bar behavior will work.
这篇关于通过点击状态栏滚动到 UITableView 的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!