Reputation: 1217
I have a view controller with GMGridView in which I have 4 GMGridViewCells. For each cell view I am using individual view controller view's as the content view of the cell.My view controllers which are being loaded into the GMGridVeiwCell's are having buttons. When I tap on the buttons within the GMGridViewCell the IBAction methods of the buttons are not getting called. Can anyone help me on this? How can I catch the button actions?
Upvotes: 0
Views: 214
Reputation: 33428
A simple solution is to override - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
in GMGridView
class like this one:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if(gestureRecognizer == _tapGesture) {
UIView* touchedView = [touch view];
if([touchedView isKindOfClass:[UIButton class]]) {
return NO;
}
}
return YES;
}
Said this, you could rely on this discussion for further info: GMGridView discussion.
Let me know if this does fix the problem. Furthermore, why do you a controller for each custom view? I think the simplest manner to achieve your goal is to create a delegate for your custom view. The delegate will be the controller that contains the GMGridView
. When you click the button in the custom view, you call the delegate and then respond according.
Hope that helps.
Upvotes: 2