2010-11-12 92 views
0

我開發了一個iPhone應用程序,它使用Shake Gesture旋轉選取器視圖的輪子。我使用IOS 3.2作爲基礎sdk。我有一個iPhone 3GS更新IOS 4.0,當我在這款3GS手機上執行我的應用程序時,它與Shake Gesture正常工作。但是當我在iPhone 4中運行它時,Shake手勢沒有反應。我沒有得到它的原因,如果有人是具有Solotion請幫我...下面我提供我HV用於處理擺動姿態守則的一部分....Shake Gesture在iPhone 4中不起作用,不知道爲什麼......?

#define kRowMultiplier   20 
#define kAccelerationThreshold  2.2 
#define kUpdateInterval   (1.0f/10.0f) 



(void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate: UIAcceleration*)acceleration{ 

    if (fabsf(acceleration.x) > kAccelerationThreshold || fabsf(acceleration.y) > kAccelerationThreshold || fabsf(acceleration.z) > kAccelerationThreshold) {  
     [progressView startAnimating]; 

     if (! isSpinning) 
     {  
      if(!btnRegion.selected && !btnFlavor.selected && !btnPrice.selected) 
      { 
       // Need to have it stop blurring a fraction of a second before it stops spinning so that the final appearance is not blurred. 
       [self stopBlurring]; 
       wheelingTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(shufflePickerView) userInfo:nil repeats:YES]; 
      } 
      else 
      { 
       [self shufflePickerView]; 
       [self performSelector:@selector(stopBlurring) withObject:nil afterDelay:2.7]; 
      } 
     } 
     isSpinning = YES;  
    } 

} 

被sumthing代碼錯誤...我可以通過模擬器在IOS 4.0上測試它嗎?或者我需要僅使用iPhone 4 ...?

回答

2

感謝雨果的解決方案,但我得到了另一種方式之前多少天做ñ我想它很容易...

我們可以通過這種方式做到這一點...

-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{ 

    if (event.type == UIEventSubtypeMotionShake) 
    { 
       //Put your code here what you want to do on a shake... 
    } 
} 
相關問題