Swift 3 to Swift 5 UIImagePickerController

Hello,

im trying to select a photo from the gallery or take a new photo but after migrating to swift 5 it does not work

Any ideas?

func openCamera() {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
imagePicker.sourceType = .camera
imagePicker.allowsEditing = true
imagePicker.modalPresentationStyle = .fullScreen

imagePicker.delegate = self

self.present(imagePicker, animated: true, completion: nil)
}
}

What do you mean by “it does not work”? Do you get a compiler error? Or trap at runtime? Or some other misbehaviour?

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

i get this, app keeps running but when i click the camera button to open it does not do anything
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x600000dbf020 UIView:0x7fe7985b0570.width == - 16 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000dbf020 UIView:0x7fe7985b0570.width == - 16 (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

Layout constraints are a very Apple-specific technology, and thus largely off-topic for Swift Forums. They are also outside of my area of expertise (I generally focus on lower-level stuff), although I’m pretty sure that this problem in not related to the Swift 3-to-5 transition but rather the updates to Xcode and frameworks that come along with it.

My advice is that you ask this question somewhere dedicated to iOS development, like the App Frameworks > Cocoa Touch topic area on DevForums. If that doesn’t pan out, you should open a DTS tech support incident and talk to one of my colleagues who specialises in UI frameworks.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

ty for the reply.

the 2nd answer did the job for me (not the approved one)