WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

UIImagePicker sheet disappears when search field takes focus

Forums > SwiftUI

I was working through your Image picker sample https://www.hackingwithswift.com/books/ios-swiftui/importing-an-image-into-swiftui-using-uiimagepickercontroller

When I was testing it on my physical device iPhone Xs Max 14.4, I noticed that whenever the search field in the picker is given focus the keyboard pops up (as you would expect) and immediately the sheet with the Image Picker disappears! Screenshot https://ibb.co/12N0NKP

This search field is not available on all configurations (the iPhone 12 Max simulator doesn't show it for example) this makes the issue even more dangerous because only some of you users will be upset!

I was wondering if this is a known issue or limited to SwiftUI sheets. I was hoping for a workaround because the ImagePicker view is very elegant when it works. I was thinking it might not disappear if the sheet was fullscreen and modal, so I tested with .fullscreencover() and .popover() and hit the same problem, and I could not see how to 'make this modal'. I also looked for a way to use .alert(), but it does not seem flexible enough to allow its content to be the ImagePicker view (but I am new to SwiftUI so I could be missing something)

Any suggestions/alternatives are much appreciated.



I have the same issue.


Hey @markreynoldson and @lucaspozzi - I'm still seeing this behavior today. Have either of you found a solution?


I have tried this on different simulator and the search bar does not show on any, however it seem to on real devices. I have test on iPhone X (my test phone) and works fine. Will try out on iPhone 12 Pro Max when I get a chance. But to me just look like simulator not showing search bar.


In my testing, using the search bar crashes on an iPhone 12, but not on an iPhone 8 or iPad Pro 9.7.. weird! The iPhone 12 is on 14.5... the others on 14.4.2.. will update and continue to test


Update: iOS version doesn't seem to affect it.


Hi all,

I have the same issue. Does anyone has solved this problem yet?

thank you michael


Hi, I have the same issue


Same issue here (May 2022, iOS 15.4.1)


Save 50% in my Black Friday sale.

SAVE 50% To celebrate WWDC22, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.