[ios] Fix build.

This commit is contained in:
Ilya Grechuhin 2016-01-04 11:48:13 +03:00
parent 416cdd7ab9
commit 02b368ac12

View file

@ -13,17 +13,18 @@
[UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
CGPoint origin = {};
CGSize size = self.collectionView.frame.size;
CGFloat const position = (CGFloat)indexPath.item / self.buttonsCount;
NSUInteger const buttonsCount = self.buttonsCount;
CGFloat const position = (CGFloat)indexPath.item / buttonsCount;
attr.hidden = (size.width == 0.0 || size.height == 0.0);
if (size.width > self.layoutThreshold)
{
origin = {nearbyint(position * size.width), 0.0};
size.width = nearbyint(size.width / self.buttonsCount);
origin.x = nearbyint(position * size.width);
size.width = nearbyint(size.width / buttonsCount);
}
else
{
origin = {0.0, nearbyint(position * size.height)};
size.height = nearbyint(size.height / self.buttonsCount);
origin.y = nearbyint(position * size.height);
size.height = nearbyint(size.height / buttonsCount);
}
NSAssert(!CGSizeEqualToSize(size, CGSizeZero), @"Invalid cell size");
attr.frame = {origin, size};
@ -32,8 +33,9 @@
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
NSMutableArray * attrs = [NSMutableArray arrayWithCapacity:self.buttonsCount];
for (NSUInteger index = 0; index < self.buttonsCount; index++)
NSUInteger const buttonsCount = self.buttonsCount;
NSMutableArray * attrs = [NSMutableArray arrayWithCapacity:buttonsCount];
for (NSUInteger index = 0; index < buttonsCount; index++)
{
NSIndexPath * indexPath = [NSIndexPath indexPathForItem:index inSection:0];
[attrs addObject:[self layoutAttributesForItemAtIndexPath:indexPath]];