2012-03-12 68 views

回答

1

使用的touchesBegan,touchesmoved,touchesEnd

1

嗯,這聽起來像你應該做的手勢識別,入住手勢時,在UIGestureRecognizerStateBegan狀態。例如:

- (void)handlePan:(UIGestureRecognizer *)sender { 

    CGPoint translation = [(UIPanGestureRecognizer*)sender translationInView:self.view];  

    switch (sender.state) { 

     case UIGestureRecognizerStateBegan: 

      if (sqrt(translation.x * translation.x)/sqrt(translation.y * translation.y) < 1) 
       isHorizontalScroll = YES; 
      else 
       isHorizontalScroll = NO; 

      break; 

     case UIGestureRecognizerStateChanged: 

      ... 
+0

的問題是,我要知道方向前handlePan將被調用 – Radislav 2012-03-12 09:45:06

1

其實具體實現取決於你。要做到這一點,您至少需要3次槓槓:

  1. 使用手勢識別器。
  2. 重新實現UIResponder的方法:

    – touchesBegan:withEvent: 
    
    – touchesMoved:withEvent: 
    
    – touchesEnded:withEvent: 
    
  3. 重新實現一個UIWindow的方法:

    – (void)sendEvent:(UIEvent *)event 
    
相關問題