Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue when layout is rotated #100

Merged
merged 2 commits into from
May 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CHTCollectionViewWaterfallLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (CGFloat)itemWidthInSectionAtIndex:(NSInteger)section {
} else {
sectionInset = self.sectionInset;
}
CGFloat width = self.collectionView.frame.size.width - sectionInset.left - sectionInset.right;
CGFloat width = self.collectionView.bounds.size.width - sectionInset.left - sectionInset.right;
NSInteger columnCount = [self columnCountForSection:section];
return CHTFloorCGFloat((width - (columnCount - 1) * self.minimumColumnSpacing) / columnCount);
}
Expand Down Expand Up @@ -248,7 +248,7 @@ - (void)prepareLayout {
sectionInset = self.sectionInset;
}

CGFloat width = self.collectionView.frame.size.width - sectionInset.left - sectionInset.right;
CGFloat width = self.collectionView.bounds.size.width - sectionInset.left - sectionInset.right;
NSInteger columnCount = [self columnCountForSection:section];
CGFloat itemWidth = CHTFloorCGFloat((width - (columnCount - 1) * self.minimumColumnSpacing) / columnCount);

Expand All @@ -275,7 +275,7 @@ - (void)prepareLayout {
attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]];
attributes.frame = CGRectMake(headerInset.left,
top,
self.collectionView.frame.size.width - (headerInset.left + headerInset.right),
self.collectionView.bounds.size.width - (headerInset.left + headerInset.right),
headerHeight);

self.headersAttribute[@(section)] = attributes;
Expand Down Expand Up @@ -342,7 +342,7 @@ - (void)prepareLayout {
attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:CHTCollectionElementKindSectionFooter withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]];
attributes.frame = CGRectMake(footerInset.left,
top,
self.collectionView.frame.size.width - (footerInset.left + footerInset.right),
self.collectionView.bounds.size.width - (footerInset.left + footerInset.right),
footerHeight);

self.footersAttribute[@(section)] = attributes;
Expand Down
8 changes: 4 additions & 4 deletions CHTCollectionViewWaterfallLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
}else{
insets = self.sectionInset
}
let width:CGFloat = self.collectionView!.frame.size.width - sectionInset.left-sectionInset.right
let width:CGFloat = self.collectionView!.bounds.size.width - sectionInset.left-sectionInset.right
let spaceColumCount:CGFloat = CGFloat(self.columnCount-1)
return floor((width - (spaceColumCount*self.minimumColumnSpacing)) / CGFloat(self.columnCount))
}
Expand Down Expand Up @@ -166,7 +166,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
sectionInsets = self.sectionInset
}

let width = self.collectionView!.frame.size.width - sectionInset.left - sectionInset.right
let width = self.collectionView!.bounds.size.width - sectionInset.left - sectionInset.right
let spaceColumCount = CGFloat(self.columnCount-1)
let itemWidth = floor((width - (spaceColumCount*self.minimumColumnSpacing)) / CGFloat(self.columnCount))

Expand All @@ -182,7 +182,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{

if heightHeader > 0 {
attributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: CHTCollectionElementKindSectionHeader, withIndexPath: NSIndexPath(forRow: 0, inSection: section))
attributes.frame = CGRectMake(0, top, self.collectionView!.frame.size.width, heightHeader)
attributes.frame = CGRectMake(0, top, self.collectionView!.bounds.size.width, heightHeader)
self.headersAttributes.setObject(attributes, forKey: (section))
self.allItemAttributes.addObject(attributes)

Expand Down Expand Up @@ -235,7 +235,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{

if footerHeight > 0 {
attributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: CHTCollectionElementKindSectionFooter, withIndexPath: NSIndexPath(forItem: 0, inSection: section))
attributes.frame = CGRectMake(0, top, self.collectionView!.frame.size.width, footerHeight)
attributes.frame = CGRectMake(0, top, self.collectionView!.bounds.size.width, footerHeight)
self.footersAttributes.setObject(attributes, forKey: section)
self.allItemAttributes.addObject(attributes)
top = CGRectGetMaxY(attributes.frame)
Expand Down