[英]Shake Gesture isn't working in iPhone 4, Don't know why…?
I have developed an iPhone app which uses Shake Gesture to rotate the wheel of picker view. 我开发了一款iPhone应用程序,它使用Shake Gesture旋转拾取器视图的轮子。 I am using IOS 3.2 as base sdk.
我使用IOS 3.2作为基础sdk。 I have a iPhone 3GS which is updated with IOS 4.0, when I execute my App in this 3GS phone it is working properly with Shake Gesture.
我有一个用IOS 4.0更新的iPhone 3GS,当我在这部3GS手机中执行我的应用程序时,它可以与Shake Gesture一起正常使用。 but when I run it in iPhone 4 the Shake Gesture doesn't respond.
但是当我在iPhone 4中运行时,Shake Gesture没有响应。 I am not getting the reason of it, if anybody is having the Solotion please help me out... Below i am providing a code part which i hv used to handle Shake Gesture....
我没有得到它的原因,如果有人正在使用Solotion,请帮助我...下面,我提供我用来处理Shake Gesture的代码部分。
#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;
}
}
is sumthing wrong in code... Can I test it by Simulator on IOS 4.0 or i need to hv a iPhone 4 only...? 代码中存在错误...我可以在IOS 4.0上通过模拟器进行测试,还是仅需要iPhone 4 ...?
Thanks Hugo for the Solution, But i got another way to do it before many days n I guess its quite easy... 感谢Hugo提供的解决方案,但是我还有另一种方法可以在很多天之前做到这一点我觉得很容易......
we can do it by this way... 我们可以这样
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if (event.type == UIEventSubtypeMotionShake)
{
//Put your code here what you want to do on a shake...
}
}
I have the exact same problem. 我有完全一样的问题。 My code tested on an iPhone 3G works fine, on an iPhone 4 it doesn't work.
我在iPhone 3G上测试的代码运行良好,在iPhone 4上它不起作用。 Both running on iOS 4.2.1
两者都在iOS 4.2.1上运行
UPDATE: Used this method and it works great: http://www.softvelopment.com/index.php/blogs/2010/03/19/3-adding-shake-recongnition-to-cocos2d-iphone-library- 更新:使用这种方法,效果很好: http : //www.softvelopment.com/index.php/blogs/2010/03/19/3-adding-shake-recongnition-to-cocos2d-iphone-library-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.