Estoy intentando arrastrar un UIImageView alrededor de la pantalla del iphone en mi aplicación.iPhone SDK: Problemas para arrastrar un UIImageView
Actualmente La funcionalidad de arrastre que he configurado está bien y al arrastrar la imagen la mueve por la pantalla, el problema es que no tiene que arrastrar la vista de imagen para moverla, también puede arrastrar a cualquier parte del pantalla y moverá la imagen. Soy nuevo en esta plataforma, así que no puedo pensar qué hacer para resolver este problema. Mi código actual para arrastrar la imagen es:
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint pt = [[touches anyObject] locationInView:pig];
startLocation = pt;
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint pt = [[touches anyObject] locationInView:pig];
CGRect frame = [pig frame];
frame.origin.x += pt.x - startLocation.x;
frame.origin.y += pt.y - startLocation.y;
[pig setFrame: frame];
}
Cualquier ayuda apreciada. Por cierto, cerdo es el UIImageView. También he notado que si configuro la interacción del usuario de la Vista de imagen "pig" para habilitarla, la imagen ya no se puede arrastrar, pero cuando no está configurada como habilitada, lo es.
Muchas gracias, ¡eso funcionó a la perfección! – Sam
self.userInteractionEnabled = YES; ... Siempre es lo mismo, y siempre es lo que estoy haciendo mal! Thanx epatel, genial :-) –