When a foreground app gets backgrounded (e.g. Home button gets pressed), how can I change elements on the topmost view controller prior to when iOS takes a snapshot of it and starts the animation to show the next screen?
I ask because I'm writing an app requiring HIPAA compliance, and I am concerned that the snapshot that the OS takes in order to do this animation sometimes contains sensitive data which should not be visible even for a split second when the app gets foregrounded later.
I'm aware that view controllers have lifecycle methods such as viewWillDisappear
which might be usable, but I have a lot of controllers and I'd rather just have something in my App Delegate to handle this (e.g. by adding an opaque full-screen UIImageView overlay) rather than having to write custom code for this in every last controller.
I tried putting overlay-generating code in applicationWillResignActive
, and I've been digging with Apple's docs and Google, but it's not working. I suspect the screenshot gets taken before the app has a chance to update the screen.
Thanks!
applicationWillEnterForeground
? Or is that also a static animation until the entire resume zoom animation is done? – InheritedUIImageView
toself.window
rather than pulling thetopViewController
out of mynavigationController
and adding it there, or if it's because I put the code inapplicationDidEnterBackground
rather thanapplicationWillResignActive
. Anyway, the sensitive info is no longer displayed when foregrounding. I'll try to dig into this and write a more concise answer as soon as SO will let me. – Herv