Paging UIScrollView page size does not respond to content insets.

Originator:jelly
Number:rdar://19075189 Date Originated:25/11/2014
Status:Open Resolved:No
Product:iOS SDK Product Version:8.1
Classification:Bug Reproducible:Always
 
Summary:
When creating a paged UIScrollView (using the pagingEnabled flag), it seems logical that by applying content insets – which effectively affect the size of the viewport in much the same way as adjusting the rect with clipsToBounds disabled – should also affect the size of the page as handled by the scrolling mechanism.

Instead, this is not true: page size is equivalent to the bounds of the scrollview itself, the result of which is that when paging with insets set that should affect it, it will cause content areas to be completely skipped.

Steps to Reproduce:
1. Download the sample project I've provided.
2. Run as-is in the simulator. This will give you the *expected* results. Note that peeks of the next and previous page appear at each side.
3. Open Main.storyboard and switch on paging for the collection view.
4. Run again in the simulator. Note that now, with the default paging implementation activated, the content scrolls to what feel like arbitrary points within the content.

Expected Results:
The expected results are as per the implementation that I've provided: swiping between pages should cause the content to scroll to page offsets as adjusted by the content insets.

The solution I've determined is to create a page size based on the frame of the scroll view/collection view, adjusted for the content insets. This is done (in a somewhat clumsy but effective way) within the scrollViewWillEndDragging:withVelocity:targetContentOffset: method implemented in CollectionViewController.m.

Actual Results:
The scroll view disregards content insets and will scroll as per the frame width of the scroll view itself. The effect of which feels like the scroll view is broken and is simply scrolling to an arbitrary point within the content.

Version:
iOS 8.1

Notes:
It is possible that this is expected behaviour, and I am fully prepared for that to be your response. However, I believe that the current default behaviour is illogical and actually detrimental. I don't believe there is any use case where the existing behaviour would be useful, and it doesn't make sense for developers to have to hack around it to accomplish something that could easily be implemented.

I should also note that the attached sample project is also available on Github at https://github.com/jellybeansoup/ios-pagedcollectionview.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!