fork from UICollectionView-ARDynamicHeightLayoutCell of version v1.0
- An simple category for caculating autolayout UICollectionViewCell size. Automatic manage cell's size cache, automatic invalidate, most improve efficiency.
-
A prototype cell in storyboard
-
-registerNib:forCellReuseIdentifier:
-
-registerClass:forCellReuseIdentifier:
if your cell use autolayout , all you need just to do like this:
#import "UICollectionView+ARDynamicHeightLayoutCell.h"
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [collectionView ar_sizeForCellWithIdentifier:@"DynamicHeightCell" fixedWidth:300 configuration:^(id cell) {
//configuration your cell
FeedModel *feed = self.feeds[indexPath.row];
[cell filleCellWithFeed:feed];
}];
}
#import "UICollectionView+ARDynamicHeightLayoutCell.h"
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [collectionView ar_sizeForCellWithIdentifier:@"DynamicHeightCell" fixedHeight:400 configuration:^(id cell) {
//configuration your cell
FeedModel *feed = self.feeds[indexPath.row];
[cell filleCellWithFeed:feed];
}
}
#import "UICollectionView+ARDynamicHeightLayoutCell.h"
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [collectionView ar_sizeForCellWithIdentifier:@"DynamicHeightCell" configuration:^(id cell) {
//configuration your cell
FeedModel *feed = self.feeds[indexPath.row];
[cell filleCellWithFeed:feed];
}
}
pod 'UICollectionView-ARDynamicHeightLayoutCell_Bell'