Transfer touch to next responder or other iOS subtask

I am sure this problem will be easily resolved, but I am relatively new to iOS development. I am trying to handle passing touch events for children that are lower in drawing order on a UIView. For instance -

I am creating an advanced UIImageView to create my MoveableImage class. This class is basically a UIImageView that implements the Began, touchEnded, and touchhesMoved touches -

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{


[self showFrame];

//if multitouch dont move
if([[event allTouches]count] > 1)
{
    return;
}



    UITouch *touch = [[event touchesForView:self] anyObject ];

    // Animate the first touch
    CGPoint colorPoint = [touch locationInView:self];

    CGPoint touchPoint = [touch locationInView:self.superview];


    //if color is alpha of 0 , they are touching the frame and bubble to next responder
    UIColor *color = [self colorOfPoint:colorPoint];
    [color getRed:NULL green:NULL blue:NULL alpha:&touchBeganAlpha];
    NSLog(@"alpha : %f",touchBeganAlpha);

    if(touchBeganAlpha > 0)
    {
          [self animateFirstTouchAtPoint:touchPoint];
    }
    else {
        [super.nextResponder touchesBegan:touches withEvent:event];
    }



}

Thus, the end result is basically this: if they touch the frame of the image, and not the image inside another image that will be under it, it may respond. See this image for an example.

Passing touch to lower view

So far I have tried the following responder, however this does not solve the problem. Any help would be greatly appreciated!

- touchhesBegan Moved. Ovveriding pointInside UIView .

-(BOOL) pointInside:(CGPoint)point withEvent:(UIEvent *) event
{
  BOOL superResult = [super pointInside:point withEvent:event];
  if(!superResult)
  {
   return superResult;
  }

  if(CGPointEqualToPoint(point, self.previousTouchPoint))
  {
     return self.previousTouchHitTestResponse;
  }else{
     self.previousTouchPoint = point;
  }

  BOOL response = NO;

  //if image is nil then return yes and fall back to super
  if(self.image == nil)
   {
     response = YES;
   }

  response = [self isAlphaVisibleAtPoint:point];
  self.previousTouchHitTestResponse = response;
  return response;





}
+5
1

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event UIImageView. ( uiview, )

UIView hitTest:withEvent:, , . pointInside: withEvent: YES, subviews; .

github OBShapedButton. .

+7

All Articles