点击屏幕顶部的状态栏时,UITableView会滚动到顶部 [英] UITableView scroll to top when tapping status bar at top of the screen

查看:246
本文介绍了点击屏幕顶部的状态栏时,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];

但是当点击屏幕顶部时,桌面视图仍然不会滚动到顶部。

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

推荐答案

你必须将 scrollsToTop 设置为在层次结构中的所有其他滚动视图上。如果多个滚动视图的 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会滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆