Estoy tratando de animar un UIButton. Pero durante su animación, no hay interacción con UIButton. El comportamiento esperado es poder hacer clic en el botón mientras se mueve. He aquí el fragmento de código de la UIButton y animación:UIButton no interactuando durante la animación
selector deUIImage *cloudImage = [UIImage imageNamed:@"sprite.png"];
UIButton moveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[moveBtn setFrame:CGRectMake(0.0, 80.0, cloudImage.size.width, cloudImage.size.height)];
[moveBtn setImage:cloudImage forState:UIControlStateNormal];
[moveBtn addTarget:self action:@selector(hit:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:moveBtn];
CGPoint newLeftCenter = CGPointMake(300.0f + moveBtn.frame.size.width/2.0f, moveBtn.center.y);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5.0f];
[UIView setAnimationRepeatCount:HUGE_VALF];
moveBtn.center = newLeftCenter;
[UIView commitAnimations];
hit
sólo muestra una NSLog para mostrar si el botón de responder a ella o no. Cualquier ayuda sería apreciada.
básicamente mi animación va de izquierda a derecha, no puedo esperar hasta que termine la animación. esto frustrará el propósito de tener un botón allí en primer lugar, ya que es solo para poder tocarlo durante su movimiento. – Frank
Consulte mis ediciones. – Moshe
ah genial thx, agregué un touchBegan y detecté el rect que está siendo tocado, esto está funcionando para mí, aunque hubiera sido genial si se pudiera hacer clic en el botón durante la diapositiva de animación :( – Frank