UITableView scroll to top when tapping status bar at top of the screen

懵懂的女人 提交于 2019-12-18 10:55:21

问题


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.

I tried :

[self.tableView setScrollsToTop:YES];

but the tableview still not scroll to top when tap the top of the screen.


回答1:


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.

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.




回答2:


Thanks for all, i resolved this problem by removing all other UITableView from the parent ViewController, and then auto scroll to top was working for this UITableView..

thanks



来源:https://stackoverflow.com/questions/8951357/uitableview-scroll-to-top-when-tapping-status-bar-at-top-of-the-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!