ios - UICollectionView cells not spacing at all -
I have a collection view that is representative and own data source, and with a defined layout like this:
- (id) initWithCoder: (NSCoder *) aDecoder {self = [super initWithCoder: aDecoder]; If (self) {self.dataSource = self; Self. Delegate = self; UICollectionViewFlowLayout * Layout = [[UICollectionViewFlowLayout alloc] init]; Layout.minimumLacingSpacing = 0; Layout.sectionInset = UIEdgeInsetsMake (0, 8, 0, 8); Layout. scrollDirection = UICollectionViewScrollDirectionHorizontal; Layout. Powder references = CGSizeMake (1, 70); Layout.itemSize = CGSizeMake (60, 70); Layout.minimumInteritemSpacing = 4.0f; [Self set calculation break layout: layout]; } Healthy return; } The code is run properly in addition to the minimum interval conditions.
The result is a collection view where there is no difference in the objects of each section.
The minimum vacancy value I set should be adjusted upward, not downward, right?
So I see why the result is similar to this screen? (I gave the color of each collection, it became clear that there is no difference)
For further detail, I am logging the frame, as you can see that the third thing starts after the second (145 pixels = 85 (prefix x) + 60 (Previouslight.width)) No vacancy. 2014-04-22 10: 25: 49.954 App [15172: 60b] In itself & lt; Photo & Exclamation Visual View: 0x16576630; BaseClass = UICollectionViewCell; Frame = (860; 60 70); Layer = & lt; CALayer: 0x165777a0 & gt; & Gt; 2014-04-22 10: 25: 49.955 App [15172: 60b] In itself & lt; Photo & Exclamation View: 0x16578380; BaseClass = UICollectionViewCell; Frame = (85 0; 60 70); Layer = & lt; CALayer: 0x16578520 & gt; & Gt; 2014-04-22 10: 25: 49.955 App [15172: 60b] In itself & lt; Photo & Exclamation Viewpoint: 0x16586620; BaseClass = UICollectionViewCell; Frame = (145 0; 60 70); Layer = & lt; CALayer: 0x165866c0 & gt; & Gt; What misunderstanding I am here?
I have also tried to add this method which is actually called for each section, but the result is the same. - (CGFloat) View archive: (UICollectionView *) archiveView layout: (UICollectionViewLayout *) collectionsviewviews Minimum InterSpaceFacingForctionActindexx (NSInteger) section {return 4.0f; }
using the representative methods below From which can be set the difference: // Layout: Set cell size - See the (CGSIEZ) collection: (UICollectionView *) Collections layout: (UICollectionViewLayout *) Compile ViewLayout sizeForItemAtIndexPath: ( NSIndexPath *) indexPath {// NSLog (@ "index% ld", the size of the setting for item (index) at indexPath.row; CGSize mElementSize = CGSizeMake (150, 36); Return mAlimal size;} - (CGFloat) Collection See: (UICollectionView *) Collections Layouts: (UICollectionViewLayout *) Collectionsview view minimum interSpacingForcectionActindex: (NSInteger) section {return 3.0;} - (CGFloat) view archive: (UICollectionView *) collectionView Layout: (UICollectionViewLayout *) Collection ViewLayout minimumLineSpacingForSectionAtIndex: (NSInteger) section {return 7.0; } // Layout: Set Edge - (UIEdgeInsets) collectionView: (UICollectionView *) collectionView Layout: (UICollectionViewLayout *) Collection ViewLayout insetForSectionAtIndex: (NSInteger) section {// Return UIEdgeInsetsMake (0,8,0,8); // Top, left, bottom, right return UIEdgeInsetsMake (0,0,0,0,0,0); // top, left, bottom, right}
Comments
Post a Comment