点击屏幕顶部的状态栏时,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 滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)