我尝试调用popoverpresentation viewcontroller以便在ipad上共享图像,但是当发生这种情况时,我会收到错误消息“无法满足约束条件”。
事情是为了解决这个问题,我删除了所有约束,所以我可以重新开始,但是即使没有约束,我也会遇到相同的错误。
所以我的问题是。这是一个错误还是我必须为popoverpresentation viewcontroller设置约束。
这是我的代码:
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.
这只是一个活动视图控制器。因此,它不是您的视图控制器,错误也不是您的问题。
您的代码是非法的,因为您正在为弹出窗口控制器分配源视图,而不是源rect。