Reputation: 86
I have developed an iPhone app which uses Shake Gesture to rotate the wheel of picker view. I am using IOS 3.2 as base 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. but when I run it in iPhone 4 the Shake Gesture doesn't respond. 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....
#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...?
Upvotes: 0
Views: 2099
Reputation: 86
Thanks Hugo for the Solution, But i got another way to do it before many days n I guess its quite easy...
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...
}
}
Upvotes: 2
Reputation: 71
I have the exact same problem. My code tested on an iPhone 3G works fine, on an iPhone 4 it doesn't work. Both running on 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-
Upvotes: 0