In my project I had created a custom layout for UICollectionView
. In that layout, vertical scrolling is NOT possible, only horizontal scrolling is possible.
If that UIViewController
is the only thing in the storyboard
, layout is working perfectly, ie, there is no vertical scrolling, only horizontal scrolling is possible.
But if you add UINavigationController
to storyboard
, layout fails in iOS 7 (tested in simulator and device). Then vertical scrolling is ENABLED. You can scroll a little amount, may be 20 or 30 points.
But for iOS 6, layout is working perfectly with and without UINavigationController
.(tested in iPhone).
Please help.
Thanks,
SOLUTION
I found solution to this.
In iOS 7, some inset was adding automatically to UICollectionView. So to fix it, add following code to ViewController self.automaticallyAdjustsScrollViewInsets = NO;
I found solution from https://stackoverflow.com/a/18989755/3117930
Hope this is helpful to someone Thanks,
what I can tell it tries to focus on the cell that was closest to the center of the pre-transition view layout. However, if there doesn't happen to be a cell at the center of the view pre-transition then it still tries to center where the cell would be post-transition. This is very clear if you set alwaysBounceVertical/Horizontal to YES, load the view with a single cell and then perform a layout transition.
I was able to get around this by explicitly telling the collection to focus on a specific cell (the first cell visible cell, in this example) after triggering the layout update.
[self.collectionView setCollectionViewLayout:[self generateNextLayout] animated:YES];
// scroll to the first visible cell
if ( 0 < self.collectionView.indexPathsForVisibleItems.count )
{
NSIndexPath *firstVisibleIdx = [[self.collectionView indexPathsForVisibleItems] objectAtIndex:0];
[self.collectionView scrollToItemAtIndexPath:firstVisibleIdx atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:YES];
}
Hopefully this will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.