From iOS 7 onwards, a ViewController's view starts at absolute position (0,0), which means it's underneath the Nav Bar.
So if we have a tableView or any other type of Scroll view in the View, the there is a chance that the top content might get hidden by the top bars. So ViewControllers automatically adjust the content inset of subviews which are of type UIScrollView to consider the space taken by the bars.
If the ViewController is inside a NavigationController, the space typically is 64 (20 for the status bar + 44 for the Navigation Bar). Otherwise it's just 20, for the Status Bar
We can disable this automatic adjustment by setting:
self.automaticallyAdjustsScrollViewInsets = NO;
This just got deprectated in iOS 11. The new method to fix this is :
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever
No comments:
Post a Comment