Update: I got the answer from here
And here
UICollectionView cell subviews do not resize
At both the places we can get the same answer of two lines of code.
You can not see the CollectionView's contentView in XIB but it is there. So just apply the code.
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.contentView.translatesAutoresizingMaskIntoConstraints = YES;
In My ios App,
In my CollectionView,
I need a different cell sizes for iPhone 4s and iPhone 6. I am setting it programmatically, here autoresizing mask does not work.
Below is the code,
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
CGFloat itemWidth=(self.view.frame.size.width-cellMarginForCollectionView)/2;
return CGSizeMake(itemWidth, itemWidth);
}
And results come like below,
The problem is label cuts down, and imgeview also cut at Right side.