Hi. I use shake gesture for my application but i have problem!
My application is a multiview application and i want use shake gesture on the view 2. If i active shake gesture on view 2, I have to write the code below in the MainViewController.m and MyView2Controller.m to use the shake gesture.
Then if i shake the iphone, alert show on both views, and I dont want that. I want the alert to only show up in view 2. So if i inactive the code on the MainViewController.m or view 1, it no longer works in view 2!
Any help appreciated!
Here is my code :
-(BOOL)canBecomeFirstResponder {
return YES;
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake)
{
UIAlertView *alet =[[UIAlertView alloc]initWithTitle:nil message:@"Shake shake shake" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alet show];
[alet release];
self.view.backgroundColor = [UIColor orangeColor];
}
}