I have this custom back button:
- (IBAction)backToMenu:(id)sender {
[self.presentingViewController dismissModalViewControllerAnimated:YES];
}
The selectors you're testing for aren't the same as the selectors you're calling. Try the following:
if([self.presentingViewController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)])
[self.presentingViewController dismissViewControllerAnimated:(YES) completion:nil];
else if([self.presentingViewController respondsToSelector:@selector(dismissModalViewControllerAnimated:)])
[self.presentingViewController dismissModalViewControllerAnimated:YES];
else
NSLog(@"Oooops, what system is this ?!!! - should never see this !");
The important difference is that the object you're calling - self.presentingViewController
, in this case - is different from the method you're calling on that object. We call the latter a selector, and that's the bit you want to put inside the @selector()
wrapper.
Use [self dismissViewControllerAnimated:YES completion:Nil]; for iOS 6