0

I have a view controller with a inside scrollview , but when I load the view controller the its scrollview isn't start from top but its almost at half screen , like this:

enter image description here

The view controller is in pageviewcontroller but I think that its not important. I dont poste the code because I think that its not important in this case , but if its i will post it.

I tried to print the contentOffset but I get (0.0, 0.0)

3
  • stackoverflow.com/questions/18924431/… Commented Apr 26, 2016 at 13:19
  • @gianni please try following code into viewDidLoad self.automaticallyAdjustsScrollViewInsets=NO; Commented Apr 26, 2016 at 13:55
  • Are you giving scrollView constraints properly? Commented May 3, 2017 at 10:59

2 Answers 2

1

I had the same issue, And i fixed it by adding one UIView before UIScrollView ... Find the below image ...

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Add a UIView named "BgView" inside ScrollView(total scroll size) and give constraints.

enter image description here

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    scrollView.layoutIfNeeded()
    scrollView.contentSize = bgView.bounds.size
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.