ScrollView issue Swift

孤街浪徒 提交于 2019-12-25 01:49:09

问题


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:

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)


回答1:


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




回答2:


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

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

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


来源:https://stackoverflow.com/questions/36866127/scrollview-issue-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!