In my mind, these situations are all parallel:
My view controller presented another view controller fullscreen, which has now been dismissed
My view controller presented another view controller not fullscreen, which has now been dismissed
My view controller presented a popover, which has now been dismissed
My view controller pushed another view controller, which has now been popped
In every case, my view controller ceased to be the "frontmost" view controller, and then became "frontmost" again. I find it curious that iOS has no single blanket "became frontmost" event sent to my view controller that covers all these situations.
I think I can cover each of those cases individually, and I think those are all the cases I need to cover, but the resulting code is confusing and scattered:
viewDidAppear
detects popping of a pushed view controller and dismissal of a fullscreen presented view controllerpopover delegate message detect dismissal of a popover
not sure what detects dismissal of a nonfullscreen presented view controller
How do people handle this coherently and elegantly?
became frontmost
– I have very consistent results withUIViewController
'sbecomeFirstResponder
andresignFirstResponder
. See here. It's not working for child view controllers, though. – PyrethrumbecomeFirstResponder
— and it seems to not be called on the new frontmost when a presented view controller is dismissed. I don't think that's super surprising since it could trigger UI that might be disruptive — but it means it won't work for this purpose. – Fayalite