Is there a way to tell whether there is a modal UIViewController presented already, say, before calling dismissModalViewControllerAnimated
?
There are just too many answers to this question, none covering all cases. Furthermore, despite what you find in the documentation, there are two alternatives to the now deprecated modalViewController
:
If you need to know if you are modal:
BOOL modal = nil != [self presentingViewController];
If you need to know if you are covered by a modal:
BOOL hiddenByModal = nil != [self presentedViewController];
iOS6+ - use presentedViewController: Since iOS 6,
presentedViewController
should be used instead as themodalViewController
which has been deprecated
Use the property:
Deprecated - modalViewController: The controller for the active modal view—that is, the view that is temporarily displayed on top of the view managed by the receiver. (read-only)
@property(nonatomic, readonly) UIViewController *modalViewController
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With