Alex Rivera | Logout

UICollectionView align logic missing in horizontal paging scrollview

Asked 2012-11-05T08:44:42.870
57

I've got a UICollectionView, which works ok, until I start scrolling. Here some pics first: enter image description here

As you can see it's great. As I start scrolling (paging enabled) the first one goes a bit offscreen: enter image description here

This is the problem. Originaly my view have 3 views and I want to scroll and show 3 views only. But as it scrolls (paging enabled) it hides a little bit of the first view and show little bit of the next first view from the next page.

And here is a video, because it's kinda hard to explain: Video of the problem (Dropbox)

Here is a picture of my UICollectionView settings: enter image description here

It's going to be great if someone can help!

Edit
Report

1 Answer

2

your UICollectionView's width should be an exact multiplication of the cell size width + the left and right insets. In your example, if the cell width is 96, then the UICollectionView's width should be (96 + 5 + 5) * 3 = 318. Or, if you wish to keep UICollectionView's 320 width, your cell size width should be 320 / 3 - 5 - 5 = 96.666.

If this does not help, your UICollectionView's width might be different than what is set in the xib file, when the application runs. To check this - add an NSLog statement to printout the view's size in runtime:

NSLog(@"%@", NSStringFromCGRect(uiContentViewController.view.frame));
answered 2012-11-18T14:08:22.393

Your Answer