Advertisement
Joze

Hittest

Feb 7th, 2012
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.         // install gesture recognizer
  3.         UITapGestureRecognizer *recognizer;
  4.         recognizer = [[UITapGestureRecognizer alloc] initWithTarget:result action:@selector(tapAction:)];
  5.         [itemView addGestureRecognizer: recognizer];
  6.         [recognizer release];
  7.  
  8.         [laView addSubview: itemView];
  9.  
  10.  
  11. -(BOOL)isInfoButtonTap:(UIGestureRecognizer*) recognizer shouldPerformInfoButtonAction:(BOOL)performAction
  12. {
  13.     BOOL ret = NO;
  14.     CGPoint location = [recognizer locationInView:self];
  15.     UIView *hitView = [self hitTest:location withEvent:nil];
  16.     if(([hitView isKindOfClass:[UIButton class]]))
  17.     {
  18.         ret = YES;
  19.         if((performAction) && (!_infoBubble))
  20.         {
  21.             [self performInfoButtonTapAnchoredToThisButton:(UIButton *)hitView];
  22.         }
  23.         else if(_infoBubble)
  24.         {
  25.             [self closeInfoBubble];
  26.         }
  27.     }
  28.    
  29.     return ret;
  30. }
  31.  
  32. - (void) tapAction: (UIGestureRecognizer*) recognizer
  33. {    
  34.     LYItemView *itemView = (LYItemView*) recognizer.view;
  35.    
  36.     if([self isInfoButtonTap:recognizer shouldPerformInfoButtonAction:YES])
  37.     {
  38.         return;
  39.     }
  40.    
  41.     (....)
  42. }
  43.  
  44.  
  45. -(void)performInfoButtonTapAnchoredToThisButton:(UIButton *)button
  46. {
  47.     (....)
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement