通过点击状态栏滚动到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?
推荐答案
你可以免费获得这个,但你应该检查 scrollsToTop 您的
UITableView
的code>属性为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屋!