I have a bunch of XIB files and I would like it so if the user shakes the device, one of the XIBs are loaded onto the screen and I was wondering how I could go about doing this.
Thanks a lot in advance! Daniel
I have a bunch of XIB files and I would like it so if the user shakes the device, one of the XIBs are loaded onto the screen and I was wondering how I could go about doing this.
Thanks a lot in advance! Daniel
There are 3 methods you can use
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
-(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
I use
-(void)motionEnded:(UIEventSubtype)motion
withEvent:(UIEvent *)event
{
// show your view
[self presentModalViewController:yourView animated:YES];
}
If you want to handle more than 1 shake event check out How do I detect when someone shakes an iPhone?