我尝试调用 popoverpresentation 视图控制器以在 ipad 上共享图像,但是当发生这种情况时,我收到错误“无法满足约束”。
问题是为了解决这个问题,我删除了所有约束,所以我可以重新开始,但即使没有约束,我也会遇到同样的错误。
所以我的问题是。这是一个错误还是我必须为 popoverpresentation 视图控制器设置约束。
这是我的代码:
print("Current device is an iPad")
print("Current device is \(UIDevice.current)")
if let imageCheck = image {
let imageToShare = [imageCheck]
let activityVC = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = super.view
self.present(activityVC, animated: true, completion: nil)
}
控制台中的错误:
Current device is an iPad
Current device is <UIDevice: 0x280c8d260>
2019-12-26 20:31:22.662290+0100 Petfie[2184:756367] [LayoutConstraints] 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:0x282f83c00 LPLinkView:0x15be4c7a0.leading == UILayoutGuide:0x2835a8c40'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x282f83840 H:[LPLinkView:0x15be4c7a0]-(59)-| (active, names: '|':_UIActivityContentTitleView:0x15be47560 )>",
"<NSLayoutConstraint:0x282f85d10 H:|-(0)-[_UIActivityContentTitleView:0x15be47560] (active, names: '|':_UINavigationBarContentView:0x15be57940 )>",
"<NSLayoutConstraint:0x282f85d60 _UIActivityContentTitleView:0x15be47560.trailing == _UINavigationBarContentView:0x15be57940.trailing (active)>",
"<NSLayoutConstraint:0x282f9eb20 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x15be57940.width == 0 (active)>",
"<NSLayoutConstraint:0x282f83b10 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x2835a8c40'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIActivityContentTitleView:0x15be47560 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x282f83c00 LPLinkView:0x15be4c7a0.leading == UILayoutGuide:0x2835a8c40'UIViewLayoutMarginsGuide'.leading (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.