问题描述
我在另一个 UIViewController
的视图中插入了一个 UITableView
.但是当我点击屏幕顶部的状态栏时;表格视图不会滚动到顶部,这是 iOS 应用程序中的预期行为.
I inserted a UITableView
inside another UIViewController
's view.
but when I tap the status bar at the top of the screen; the table view doesn't scroll to the top which is the expected behavior within iOS apps.
我试过了:
[self.tableView setScrollsToTop:YES];
但是当点击屏幕顶部时tableview仍然没有滚动到顶部.
but the tableview still not scroll to top when tap the top of the screen.
推荐答案
您必须在层次结构中的所有其他滚动视图上将 scrollsToTop
设置为 NO
.如果多个滚动视图将 scrollsToTop
设置为 YES
,则在触摸状态栏时它们都不会滚动到顶部.这在 scrollsToTop
属性的文档中有所提及.
You have to set scrollsToTop
to NO
on all the other scroll views in your hierarchy. If more than one scroll view has scrollsToTop
set to YES
, none of them will scroll to top when the status bar is touched. This is mentioned in the documentation of the scrollsToTop
property.
请记住,这也适用于视图层次结构中 UIScrollView
的任何子类,以及 UITableView
、UIContainerView
和 >UITextView
是 UIScrollView
的子类.
Keep in mind that this also applies to any subclasses of UIScrollView
in your view hierarchy, and that UITableView
, UIContainerView
, and UITextView
are subclasses of UIScrollView
.
这篇关于点击屏幕顶部的状态栏时,UITableView 滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!