Permalink
Browse files

multiply the width's content size by 2 to fix some glitch

  • Loading branch information...
1 parent 506d3e9 commit 3e34a31025d0b28607ea16fb7ab12aa876929cf6 @ikhsan committed Jul 19, 2013
Showing with 11 additions and 11 deletions.
  1. +7 −11 IAInfiniteGridView/IAInfiniteGridView.m
  2. +4 −0 Infinite/Infinite/IAViewController.m
View
18 IAInfiniteGridView/IAInfiniteGridView.m
@@ -64,7 +64,7 @@ - (void)calculateContentSize {
totalGridSize.width += [self.dataSource infiniteGridView:self widthForIndex:i];
}
- self.contentSize = CGSizeMake(totalGridSize.width, totalGridSize.height);
+ self.contentSize = CGSizeMake(totalGridSize.width * 2, totalGridSize.height);
self.containerView.frame = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height);
}
@@ -255,9 +255,7 @@ - (void)tileGridsFromMinX:(CGFloat)minimumVisibleX toMaxX:(CGFloat)maximumVisibl
- (UIView *)gridViewAtPoint:(CGPoint)point {
__block UIView *gridView = nil;
- [self.visibleGrids enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- UIView *visibleGridView = (UIView *)obj;
-
+ [self.visibleGrids enumerateObjectsUsingBlock:^(UIView *visibleGridView, NSUInteger idx, BOOL *stop) {
if (CGRectContainsPoint(visibleGridView.frame, point)) {
gridView = visibleGridView;
*stop = YES;
@@ -270,13 +268,11 @@ - (UIView *)gridViewAtPoint:(CGPoint)point {
#pragma mark - Scroll View Delegate Methods
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (self.isPaging) {
- if ([self.gridDelegate respondsToSelector:@selector(infiniteGridView:didScrollToPage:)]) {
- UIView *grid = [self gridViewAtPoint:scrollView.contentOffset];
- if (grid.tag != self.currentPageIndex) {
- self.currentPageIndex = grid.tag;
- [self.gridDelegate infiniteGridView:self didScrollToPage:grid.tag];
- }
+ if ([self.gridDelegate respondsToSelector:@selector(infiniteGridView:didScrollToPage:)]) {
+ UIView *grid = [self gridViewAtPoint:scrollView.contentOffset];
+ if (grid && grid.tag != self.currentPageIndex) {
+ self.currentPageIndex = grid.tag;
+ [self.gridDelegate infiniteGridView:self didScrollToPage:grid.tag];
}
}
}
View
4 Infinite/Infinite/IAViewController.m
@@ -108,4 +108,8 @@ - (void)infiniteGridView:(IAInfiniteGridView *)gridView didSelectGridAtIndex:(NS
NSLog(@"grid index : %d", gridIndex);
}
+- (void)infiniteGridView:(IAInfiniteGridView *)gridView didScrollToPage:(NSInteger)pageIndex {
+ NSLog(@"scroll to page : %d", pageIndex);
+}
+
@end

0 comments on commit 3e34a31

Please sign in to comment.