This is a fun one... I have an application that has a help screen and is displayed as a modal view. The main view has an action that occurs when the device is shaken. I do not want the action to occur (sounds are played) when the help screen has been displayed.
I have tried a few things... here is my code:
To display the help screen:
- (IBAction)helpButtonPressed:(id) sender {
helpViewController = [[HelpViewController alloc] init];
[self presentModalViewController:helpViewController animated:YES];
}
To release the help screen:
- (IBAction)buttonPressed:(id) sender {
[self dismissModalViewControllerAnimated:YES];
}
I tried the following with no success:
if ([helpViewController.view isHidden ]) {
NSLog(@"Shake -- helpView is loaded");
} else {
NSLog(@"Shake -- helpView is not loaded");
}
if ([helpViewController isViewLoaded]) {
NSLog(@"Shake -- helpView is loaded");
} else {
NSLog(@"Shake -- helpView is not loaded");
}
if ([self isViewLoaded]) {
NSLog(@"Shake -- helpView is loaded");
} else {
NSLog(@"Shake -- helpView is not loaded");
}
What I was thinking is if there is a function to allow me to detect if the help view is showing, I will return without playing the sounds when the device is shaken....
Any ideas?