PhotosPicker won't appear when it embedded in popover

When I embedded a PhotosPickerView() in popover,

it won't works:

struct PhotoPickerTest: View {
    @State private var selectedPhotoItem: PhotosPickerItem?
    @State var isTaped: Bool = false
    
    var body: some View {
        Button("", systemImage: "plus") {
            isTaped = true
        }
        .popover(isPresented: $isTaped) {
            PhotoPickerView()
        }
    }
    
    func PhotoPickerView() -> some View {
        PhotosPicker(selection: $selectedPhotoItem) {
            Image(systemName: "photo")
        }
    }
}

but if I just replace "popover" to "sheet", it works fine:

struct PhotoPickerTest: View {
    @State private var selectedPhotoItem: PhotosPickerItem?
    @State var isTaped: Bool = false
    
    var body: some View {
        Button("", systemImage: "plus") {
            isTaped = true
        }
        .sheet(isPresented: $isTaped) {
            PhotoPickerView()
        }
    }
    
    func PhotoPickerView() -> some View {
        PhotosPicker(selection: $selectedPhotoItem) {
            Image(systemName: "photo")
        }
    }
}

I think it's a bug, and bothered me a lot, hope apple engineers can fix it.

  • Test on Vision OS 1.0, Xcode 15.2

Add a Comment

Replies

I tried in Xcode 15.0 and iOS 17 simulator and it works the same with popover of sheet.

The 3 screenshots:

What are your versions ?

  • Sorry for forgot to mention OS version, I test it in Vision OS 1.0, Xcode 15.2, it won't works.

Add a Comment

Thanks for the report! This is already tracked by 101250885.

You can use the .photosPicker view modifier to present the picker from a popover or menu.