estoy seguro de que este problema se resuelve fácilmente sin embargo yo soy relativamente nuevo en el desarrollo de iOS. Estoy tratando de manejar los eventos táctiles que pasan a los niños que están más abajo en el orden de sorteo en un UIView. Por ejemplo -táctil para el próximo respondedor u otro sub-vista iOS
puedo crear extendió UIImageView para crear mi clase MoveableImage. Esta clase es básicamente UIImageView que implementa el touchesBegan, touchesEnded y touchesMoved-
-(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];
}
}
Así, el resultado final es básicamente esto: Si ellos están tocando el marco de la imageView y no la imagen dentro de otra imagen que será debajo puede posiblemente responder. Vea esta imagen para un ejemplo.
Hasta ahora he intentado próxima respondedor sin embargo, que no resuelve el problema. ¡Cualquier ayuda sería muy apreciada!
Resolved- que se detuvo el control de la alfa en el touchesBegan y touchesMoved. Ovveriding pointInside permitió a UIView manejar eso por mí.
-(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;
}
Funcionó muy bien gracias hombre! – thebringking