So, it's better to post images to understand
I did not use any constraints here, because, when I start using constraints, constraints warning is thrown. I set the size of the cell in storyboard (159/50), min spacing is 1, and also in code
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(159, 50);
}
Also i've set "Clip Subviews" at collectionview, collectionviewcell, view in cell and button in view to NO to see where the views were placed. "Autoresize subviews" does not do anything, i've checked. Mode of each view is set to "Scale to Fit". Size of the cell can be default or custom, this also does not make sense.
So, why this is happened? I've spent 2 days on this. Please help.
I've also attach screenshots with constraints on.
I've set top, bottom, leading and trailing constraints on UIView inside cell, and UILabel inside this UIView.
but in this case I got constraints error on each device:
(
"<NSLayoutConstraint:0x7fd0834b0b10 H:[UIButton:0x7fd0834b0140'Button']-(0)-| (Names: '|':UIView:0x7fd0834b0050 )>",
"<NSLayoutConstraint:0x7fd0834b0b60 H:|-(35)-[UIButton:0x7fd0834b0140'Button'] (Names: '|':UIView:0x7fd0834b0050 )>",
"<NSLayoutConstraint:0x7fd0834b0dd0 H:|-(20)-[UIView:0x7fd0834b0050] (Names: '|':UIView:0x7fd0834aff60 )>",
"<NSLayoutConstraint:0x7fd0834b0e70 H:[UIView:0x7fd0834b0050]-(19)-| (Names: '|':UIView:0x7fd0834aff60 )>",
"<NSAutoresizingMaskLayoutConstraint:0x7fd0834b27c0 h=--& v=--& H:[UIView:0x7fd0834aff60(50)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fd0834b0b10 H:[UIButton:0x7fd0834b0140'Button']-(0)-| (Names: '|':UIView:0x7fd0834b0050 )>
I think this error occurs because cell size is not set correctly, in my case it is set to default 50x50, i've checked this.
All these problems have occurred after install xcode 6.
Funny thing: when I use UICollectionViewController
, instead of UIViewController
with UICollectionView
inside with needed delegates on, my app is working correctly.