【问题标题】:Find when a subview is touched when it is animating in iphone?查找在 iphone 中设置动画时触摸子视图的时间?
【发布时间】:2011-12-30 13:26:53
【问题描述】:

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

 - (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");
        }
    }

【问题讨论】:

    标签: iphone animation subview uitouch addsubview


    【解决方案1】:

    您应该在 Baloon 类中实现“touchesBegan”方法,并在“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;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-16
      • 2012-01-10
      • 2011-07-07
      • 2011-08-29
      • 2012-03-17
      • 2011-06-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多