I want to put a UICollectionView control that shows thumbs horizontally (only a single line of thumbs). For some reason the UICollectionView push the thumbs 44 pixels down, so the "0" height is actually "44". I assume it might be adding this space to consider the navigation bar height (I just assume). Since my UICollectionView is only on part of the screen, I don't want this margin. Is there a way to remove it?
相关问题
- CollectionView with background Image
- UICollectionViewScrollPosition not working
- @objc protocol crashes the swift compiler
- Getting UITableViewCell from its superview iOS 7 i
- UICollectionView is very slow when inserting or de
相关文章
- didBeginContact:(SKPhysicsContact *)contact not in
- ios7 new pan gesture to go back in navigation stac
- IOS UICollectionview Dynamically change Cell's
- PhoneGap iOS 7 and localStorage
- Add UITextField to title view of navigation item
- iOS7 crashing - [__NSPlaceholderDictionary initWit
- SKStoreProductViewController rate disabled on iOS
- Instead of UICollectionView a black screen is disp
The issue may be in collection view's content insets. Try to add
self.automaticallyAdjustsScrollViewInsets = NO;
into view controller'sviewDidLoad
method.Swift 3:
First you want to set the viewControllers
automaticallyAdjustsScrollViewInsets
to false:Then, you should be able to adjust the edge insets accordingly:
You can set this in the storyboard too.
Make sure you've selected the ViewController, and then untick "Adjust Scroll View Insets".
I haven't tested what this IB/Storyboard method does on iOS6 though. With the code method you need to check that the VC responds to the method:
I found that adding:
In the view controller I was loading the UICollectionView in solved the problem as I couldn't get the accepted answer to work.
The question I found this answer to can be found here and provides an extremely in-depth and interesting explanation of the difference between automatically adjusted scrolled view insets, extended layouts and edge for extended layouts.
Well worth a read
Similar to @Sviatoslav answer, you can try the following:
Maybe you can try to force this value at 0 using the Delegate flow layout of collection view :
Modify the value of your padding.