2010-11-12 80 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... 
    } 
} 
相关问题