Reputation: 1454
I use view controller with embedded in navigation controller.
In this view I added scroll view and then content view inside scroll view
I added constrains for scroll view - zero for top, bottom, leading, and trailing. And the same for content view - zero for top, bottom, leading, and trailing. And I added width and height for content view the same as main view.
Inside content view I need to add different content (labels, text fields, buttons) - this will be settings screen with vertical scroll.
Now I see that content is always shifted down a bit (the same value as menu height)
How to make to located vertically on top?
And how to put all the content in the content view that should be vertically long and scrollable vertically?
Upvotes: 4
Views: 1725
Reputation: 45
In iOS 11, automaticallyAdjustsScrollViewInsets
is deprecated and adjusting UIScrollView
's contentInsetAdjustmentBehavior
is recommended instead.
This worked for me pretty well (Swift):
scrollView.contentInsetAdjustmentBehavior = .automatic
Upvotes: 0
Reputation: 16864
Go to your viewcontroller viewDidLoad
method put following code.
self.automaticallyAdjustsScrollViewInsets=NO;
Upvotes: 0
Reputation: 1722
Just add this line to the viewDidload
method of your ViewController.
self.automaticallyAdjustsScrollViewInsets = NO;
Upvotes: 2
Reputation: 644
Go to storyboard and select the appropriate viewcontroller and Uncheck AutomaticallyadjustScrollviewInsets.
Or
Go to viewdidload self.automaticallyAdjustsScrollViewInsets=NO;
Upvotes: 0
Reputation: 7602
I think you forget to remove tick -> Adjust scrollview insects .
Upvotes: 11
Reputation: 1236
Check you attribute inspector setting in Storyboard.Uncheck
adjustScrollViewInsets
from viewcontroller storyboard.Viewcontroller Storyboard settings.
Upvotes: 0