Reputation: 1
I have an additem view where two buttons exist < take photo > < select photo> If on my phone I choose select photo first, it brings up the camera If I choose take photo it brings up the camera If I coose take photo and then close it and choose select photo, it then allows me to select from the libray as intended. I have isolated the view of take photo and select photo and they both work independently of each other but when in the same view it has an abnormal outcome? Im new to swift and stuck on this issue please help
HStack {
// Take photo button
Button(action: {
imagePickerSource = .camera // Set the source type to camera
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
showingImagePicker = true
}
}) {
Text("Take Photo")
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
// Select existing photo button
Button(action: {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
imagePickerSource = .photoLibrary
showingImagePicker = true
}
}) {
Text("Select Photo")
.padding()
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(8)
}
}
I tried linking each to a different view and they both worked as expected I tried the dispatch with no change in result
No matter what when i choose select photo first it brings up the camera subsequently when I choose take photo and close the camera operation and then choose select photo, it works for a period
am Using Swift 15 ( I didnt want to update mid coding and on native mac pro if that helps
I load the app to my iphone 12 pro max for testing the camera and library functionality
Upvotes: 0
Views: 30