bvh*_*bvh 12 ios swift swift5 xcode10.2
我昨天升级到Xcode 10.2,并开始使用Swift 5,当出现UIAlertController照片提示时会注意到此错误。我不记得在Xcode 10.1中看到过
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600001321e00 UIView:0x7fe1246070a0.width == - 16 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
Run Code Online (Sandbox Code Playgroud)
我读过此问题如何捕获UIViewAlertForUnsatisfiableConstraints?
并能够将错误定位到我的位置UIAlertController(以红色突出显示)
这是我的代码:
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600001321e00 UIView:0x7fe1246070a0.width == - 16 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
Run Code Online (Sandbox Code Playgroud)
我试图UIAlertController通过在我的promptPhoto()方法内部使用此代码来设置宽度,但无济于事。
@objc private func promptPhoto() {
let prompt = UIAlertController(title: "Choose a Photo",
message: "",
preferredStyle: .actionSheet)
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
let camerAction = UIAlertAction(title: "Camera", style: .default) { _ in
guard self.isCameraAccessible() else {
self.showAlert(title: "Oops", message: "Camera is not available")
return
}
imagePicker.sourceType = .camera
imagePicker.allowsEditing = true
self.present(imagePicker, animated: true)
}
let libraryAction = UIAlertAction(title: "Photo Library", style: .default) { _ in
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
self.present(imagePicker, animated: true)
}
let cancelAction = UIAlertAction(title: "Cancel",
style: .cancel,
handler: nil)
prompt.addAction(camerAction)
prompt.addAction(libraryAction)
prompt.addAction(cancelAction)
present(prompt, animated: true) {
// Prevent closing the prompt by touch up outside the prompt.
prompt.view.superview?.subviews[0].isUserInteractionEnabled = false
}
}
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以控制UIAlertController宽度,以便摆脱错误消息?
先感谢您。
| 归档时间: |
|
| 查看次数: |
876 次 |
| 最近记录: |