當頁面中同時有navigationBar和tabbar時,tableView向上滑到底部的時候則會出現一段空白,但是向下滑的時候是沒有空白的,具體效果如下圖:
我把tableview的背景顏色設置為了綠色
這個時候設置automaticallyAdjustsScrollViewInsets = NO; ?效果如下:
我們看到多出綠色的部分已經沒有了。
官方文檔解釋如下:
A Boolean value that indicates whether the view controller should automatically adjust its scroll view insets.
Declaration
SWIFT
var automaticallyAdjustsScrollViewInsets: Bool
OBJECTIVE-C
@property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets
Discussion
The default value of this property is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.
Availability
Available in iOS 7.0 and later.
簡單點說就是automaticallyAdjustsScrollViewInsets根據按所在界面的status bar,navigationbar,與tabbar的高度,自動調整scrollview的 inset,設置為no,不讓viewController調整,我們自己修改布局即可。