点击屏幕顶部的状态栏时,UITableView 滚动到顶部

UITableView scroll to top when tapping status bar at top of the screen(点击屏幕顶部的状态栏时,UITableView 滚动到顶部)
本文介绍了点击屏幕顶部的状态栏时,UITableView 滚动到顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在另一个 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 的任何子类,以及 UITableViewUIContainerView>UITextViewUIScrollView 的子类.

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 滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetContentOffset: 不在 UISCrollView 的边缘工作)
ImageView Scaling when scrolling down(向下滚动时 ImageView 缩放)
Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的边界自动更改,带有内容插图)
iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?)
Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定义、交互式)视图控制器呈现和解除处理滚动视图)