ios – The best way to view chosen picture with photopicker


I need assistance organising this code to have my chosen picture substitute the button, as an alternative of the picture sitting underneath the button. How do i rewrite this code to view the picture that’s changing the button that enable the person to choose the picture

   PhotosPicker(
                                    choice: $selectedItem,
                                   
                                    matching: .photographs,
                                    photoLibrary: .shared()
                                   ) {
                                       Picture(systemName: "individual.fill")
                                           .font(.system(dimension: 64))
                                           .padding()
                                   }
                                   .onChange(of: selectedItem) { newValue in
                                       Job {
                                           if let information = strive? await newValue?.loadTransferable(sort: Knowledge.self) {
                                               selectedImageData = information
                                           }
                                       }
                                   }
                                   if let selectedImageData, let uiImage = UIImage(information: selectedImageData) {
                                       Picture(uiImage: uiImage)
                                           .resizable()
                                           .scaledToFit()
                                           .body(width: 250, peak: 250)
                                          
                                           
                                   }
                               }

See also  swift - Why is the preview displayed in my customized digital camera interface totally different from the one displayed within the system digital camera in iOS growth?

Leave a Reply