UIImageView를 동적으로 만들고 애니메이션보기 (한 곳에서 다른 곳으로 이동)했습니다. 터치 이벤트를 작성하고 이미지보기에서 터치를 인식하려고했습니다. 그러나 이미지가 움직일 때 터치 이벤트를 인식 할 수 없습니다.움직이는 객체에서 터치 이벤트를 인식합니다.
하지만 이미지보기를 추가 한 초기 위치를 터치하면 인식되지만 터치가 움직이지 않는 동안에는 인식됩니다.
UIImageView *birdImage = [[UIImageView alloc] initWithFrame: CGRectMake(-67, 100, 67, 52)];
birdImage.image = [UIImage imageNamed: @"Flying_bird.png"];
birdImage.tag = 1000;
birdImage.userInteractionEnabled = YES;
[birdImage setContentMode: UIViewContentModeScaleAspectFit];
[self.view addSubview: birdImage];
[UIView animateWithDuration:10.0 delay:0.0 options: ViewAnimationOptionAllowUserInteraction animations:^{
birdImage.frame = CGRectMake(547, 100, 67, 52);
} completion:nil];
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
NSLog(@"Tag: %d", [[touch view] tag]);
}
누구든 도와주세요.
안녕하세요 Mistry, 답장을 보내 주셔서 감사합니다. 나는 또한 당신의 코드로 시도했지만 작동하지 않습니다. 내 질문을 편집했습니다. 코드를보고 내가 실수를하고 있음을 알려주십시오. – MohanVydehi