在iphone中设置动画时,是否查找子视图何时被触摸?

在iphone中设置动画时,是否查找子视图何时被触摸?,iphone,animation,subview,uitouch,addsubview,Iphone,Animation,Subview,Uitouch,Addsubview,我在视图中添加了一个子视图。我在触摸时找到它,当它为触摸设置动画时,事件正在查找子视图。。 这是代码 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch self]) { NSLog(@"View Touched"); } if

我在视图中添加了一个子视图。我在触摸时找到它,当它为触摸设置动画时,事件正在查找子视图。。 这是代码

 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        if ([touch self]) {
            NSLog(@"View Touched");
        }
        if ([[touch view] isKindOfClass:[Baloon class]]) {
            NSLog(@"Baloon Touched");
        }
    }

您应该在Baloon类中实现touchesBegind方法,并在touchesMove方法中将新位置设置为Baloon

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


  NSSet *allTouches = [event allTouches];
  switch ([allTouches count]) {
    case 1: {
      UITouch *touch = [[allTouches allObjects] objectAtIndex:0];

      [self setCenter:[touch locationInView:self.superview]];
    }
      break;
    default:
      break;
  }
}