Skip to content
Open
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
1 change: 1 addition & 0 deletions GMGridView/GMGridView.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ typedef enum
- (void)swapObjectAtIndex:(NSInteger)index1 withObjectAtIndex:(NSInteger)index2 animated:(BOOL)animated;
- (void)swapObjectAtIndex:(NSInteger)index1 withObjectAtIndex:(NSInteger)index2 withAnimation:(GMGridViewItemAnimation)animation;
- (void)scrollToObjectAtIndex:(NSInteger)index atScrollPosition:(GMGridViewScrollPosition)scrollPosition animated:(BOOL)animated;
- (void)scrollToPageIndex:(NSInteger)index animated:(BOOL)animated;

// Force the grid to update properties in an (probably) animated way.
- (void)layoutSubviewsWithAnimation:(GMGridViewItemAnimation)animation;
Expand Down
34 changes: 33 additions & 1 deletion GMGridView/GMGridView.m
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,22 @@ - (void)contentOffset:(CGPoint)contentOffset
//////////////////////////////////////////////////////////////
#pragma mark GestureRecognizer delegate
//////////////////////////////////////////////////////////////
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ( gestureRecognizer == _tapGesture) {
if ( [touch.view isDescendantOfView:self] ) {
// Test if the touched view is a subview of a control
for ( UIView *view = touch.view ; view != self ; view = view.superview )
if ( [view isKindOfClass:[UIControl class]] )
return NO;
}
}

return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
{
return YES;
}

Expand Down Expand Up @@ -1611,6 +1624,25 @@ - (void)scrollToObjectAtIndex:(NSInteger)index atScrollPosition:(GMGridViewScrol
];
}

- (void)scrollToPageIndex:(NSInteger)index animated:(BOOL)animated
{
int pages = [self.layoutStrategy numberOfPages];
if(index >= 0 && index < pages)
{
int scrollToX = self.frame.size.width * index;
[UIView animateWithDuration:animated ? kDefaultAnimationDuration : 0
delay:0
options:kDefaultAnimationOptions
animations:^{
[self setContentOffset:CGPointMake(scrollToX, 0) animated:NO];
}
completion:^(BOOL finished){
}
];

}
}

- (void)insertObjectAtIndex:(NSInteger)index animated:(BOOL)animated
{
[self insertObjectAtIndex:index withAnimation: animated ? GMGridViewItemAnimationScroll : GMGridViewItemAnimationNone];
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions GMGridView/GMGridViewLayoutStrategies.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ typedef enum {

- (NSRange)rangeOfPositionsInBoundsFromOffset:(CGPoint)offset;

@optional
- (NSInteger)numberOfPages;

@end


Expand Down
5 changes: 5 additions & 0 deletions GMGridView/GMGridViewLayoutStrategies.m
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ - (NSRange)rangeOfPositionsInBoundsFromOffset:(CGPoint)offset
return NSMakeRange(firstPosition, (lastPosition - firstPosition));
}

- (NSInteger)numberOfPages
{
return _numberOfPages;
}

@end


Expand Down