2012-04-21 33 views
0

是否有任何方法可以將對象從一個視圖添加到另一個視圖,並讓對象立即跟隨用戶的手指。 A UIImageView存在於UIScrollView內。您可以使用UILongPressGestureRecognizer將其從UIScrollView中刪除,將其添加到整體視圖中。將對象添加到不同視圖並立即跟隨手指

我想要imageview然後按照主視圖上的觸摸。 UIImageView有一個UIPanGesture來控制運動。問題是,在長時間和平底鍋之間,你必須擡起手指並重新敲擊屏幕。有什麼方法可以將對象添加到主視圖中,並且它已經在用戶的手指之後而不必擡起手指?

回答

0

通過捕捉UILongPressGestureRecognizer的當前狀態,您可以在長時間按下後檢測手指的移動。例如:

識別器聲明:

UILongPressGestureRecognizer* Long = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressDetected:)]; 

方法實現:

-(void)longPressDetected:(UILongPressGestureRecognizer*)Long{ 

    switch ([Long state]) { 
     case UIGestureRecognizerStatePossible: 

      break; 

     case UIGestureRecognizerStateBegan: 

      NSLog(@"Got it!")l // Long press is successfully recognized 
      break; 


     case UIGestureRecognizerStateChanged: 


      NSLog(@"Wow! Its moving!"); // finger position has changed 

      break; 

     case UIGestureRecognizerStateEnded: 


     default: 
      break; 
    } 
} 
相關問題