iOS7 UIScrollView在状态栏下方显示偏移量内容
我正在开发我的应用程序以使用iOS7。
我有一个UINavigationController我正在推动一个内部有ScrollView的UIViewController。在scrollView里面我有一个tableView。
当我在scrollView中滚动tableView时,可以实现这一点,列表将显示在状态栏后面。同样的原因,如果我有一个UINavigationController和一个带有tableView的UIViewController。
I'm developing my app to work with iOS7. I have a UINavigationController I'm pushing a UIViewController that has a ScrollView inside it. Inside the scrollView I have a tableView. Is it possible to achieve that when I scroll the tableView inside the scrollView the list will appear behind that Status bar. Same why it would be if I had a UINavigationController and a UIViewController with a tableView in it.
所以这就是层次结构:
UINavigationController - > UIViewCOntroller - > UIScrollView - > UITableView。
UINavigationController -> UIViewCOntroller -> UIScrollView -> UITableView .
我希望当用户滚动表格时,顶部的单元格将在状态栏下显示。
and I want that when a user scroll the table,the cells in the top will be visible under the status bar.
如果没有UISCrollView,它会在iOS7中自动发生。
If there is not UISCrollView it happens automatically in iOS7.
谢谢。
只需将 automaticAdjustsScrollViewInsets
设置为否
在viewController init方法中。
Just set automaticallyAdjustsScrollViewInsets
to NO
in the viewController init method.
在Storyboard中,当选择UIViewController时,可以直接在属性面板中切换属性。
In Storyboard, you can switch the property directly in the property panel when the UIViewController is selected.
如果你使用xib,只需这样设置:
If you use xib, just set it like this:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self.automaticallyAdjustsScrollViewInsets = NO;
}
注意:这是从iOS7开始,仍然在iOS8中。
Note: this is right since iOS7 and still in iOS8.