UITableView scroll to top when tapping status bar at top of the screen(点击屏幕顶部的状态栏时,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
的任何子类,以及 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 滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:点击屏幕顶部的状态栏时,UITableView 滚动到顶部


- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01