問題描述
我在另一個 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 滾動到頂部的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!