Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this UIScrollView not behave properly?

I have a project where I need a custom tabbar, a navigationcontroller and a pageviewcontroller in one view. I have succeeded in creating this, but I am encountering a bug that I cannot solve:

The first viewcontroller in my pageviewcontroller does not set its view height properly (or rather its Y value). The moment scrolling occurs this gets set to the correct height.

I have created a minimal testproject here.

Edit: I have tried setting collectionView.contentInset and automaticallyAdjustsScrollViewInsets with all possible combinations, but to no avail. Anyone?

like image 619
vrwim Avatar asked Jan 08 '16 09:01

vrwim


2 Answers

You were confused with navigation bar and bottom bar. Here is how it should work in you project in storyboard for PageViewController:

enter image description here

Also, I removed line automaticallyAdjustsScrollViewInsets = false, and unchecked it in storyboard.
You can get fixed project here

like image 184
shpasta Avatar answered Oct 22 '22 10:10

shpasta


Try to add automaticallyAdjustsScrollViewInsets = false for your pageviewcontroller. Notice the first page is not under top bar, while it is after scrolling.

like image 40
gabbler Avatar answered Oct 22 '22 10:10

gabbler