UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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.

Mark.

4      

I have the same issue.

3      

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

3      

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.

3      

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

3      

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

3      

Hi all,

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

thank you michael

3      

Hi, I have the same issue

3      

Same issue here (May 2022, iOS 15.4.1)

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.