Is there a way to know if a UIViewController has been presented and dismissed modally ?
Something like:
- hasBeenPresentedModally
- hasBeenDismissedModally
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s nothing built in, but a view controller could, upon receiving
viewDidAppearand/orviewWillDisappearcheck whether it has aparentViewController, since per Apple’s documentation (emphasis added):If it has then it can set suitable flags for future reference.
Note that being presented modally is different from being truly modal. For example, on an iPad you might put one controller inside a
UIPopoverController, so that controller isn’t presented modally, but then it might modally present another controller on top of itself. So the second controller is presented modally but isn’t itself a modal dialogue because — if the program is otherwise set up suitably — the user can just ignore the popover entirely.