Search code examples
iosobjective-cuiimagepickercontrolleruidocumentpickerviewcontroller

How to detect that UIImagePickerController or UIDocumentPickerController window is opened


I am displaying overlay custom view in my app. I find the key window, and I add my overlay custom view to the key window's subview. And I set the overlay custom view's layer.zposition to 1.

When I open the UIImagePickerController or UIDocumentPickerViewController, I can't touch anything (It works nothing including cancel button in UIImagePickerController) and my overlay custom view is still exists.

So I'm trying to detect that UIImagePickerController or UIDocumentPickerViewController window is open. And If it's opened, I will make my overlay custom view's layer.zposition lower. And the Album will touched.

How can I get the event that UIImagePickerController or UIDocumentPickerViewController is opened?


Solution

  • There is two ways to know when these controllers are being presented:

    1. You can override presentViewController:animated:completion: method for your root view controller, in that this method check if viewControllerToPresent is class type of UIImagePickerController or UIDocumentPickerViewController. and making the needed changes around overlay view.
    2. I hope you only presenting these controllers from your source code, in that case before presenting these view controller you can make need change.