Why is ActivityViewController displaying auto constraint errors in console?

穿精又带淫゛_ 提交于 2020-06-29 11:35:16

问题


I'm trying to implement a share button in my application and so naturally, I turned to UIActivityViewController. For some reason, any time I press the share button and it pops up, I get the following message in my log:

    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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7c0a65d0 V:[UIView:0x7c0a2fa0(<=528)]>",
    "<NSLayoutConstraint:0x7c0a6540 UIView:0x7c0a2fa0.height == UIView:0x7c0a2e60.height>",
    "<NSLayoutConstraint:0x7c0a7100 _UIAlertControllerView:0x7c0a27f0.height == UIView:0x7c0a2e60.height>",
    "<NSLayoutConstraint:0x7c0b1660 V:[_UIAlertControllerView:0x7c0a27f0(568)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7c0a65d0 V:[UIView:0x7c0a2fa0(<=528)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-06-20 15:32:43.885 App[19268:300248] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x78fc3e70 V:[UIView:0x78ff1eb0(<=528)]>",
    "<NSLayoutConstraint:0x78fc3de0 UIView:0x78ff1eb0.height == UIView:0x78fb9670.height>",
    "<NSLayoutConstraint:0x78fc5aa0 _UIAlertControllerView:0x78ff69f0.height == UIView:0x78fb9670.height>",
    "<NSLayoutConstraint:0x78f58860 V:[_UIAlertControllerView:0x78ff69f0(568)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x78fc3e70 V:[UIView:0x78ff1eb0(<=528)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-06-20 15:32:48.691 App[19268:300248] viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x79982700 {Message=Service Connection Interrupted}

I am not doing anything fancy when calling it, just the bare minimum:

let someText:String = "Hello"
        let activityViewController = UIActivityViewController(activityItems: [someText], applicationActivities: nil)
        activityViewController.excludedActivityTypes =  [
            UIActivityTypePostToWeibo,
            UIActivityTypePrint,
            UIActivityTypeCopyToPasteboard,
            UIActivityTypeAssignToContact,
            UIActivityTypeSaveToCameraRoll,
            UIActivityTypeAddToReadingList,
            UIActivityTypePostToFlickr,
            UIActivityTypePostToVimeo,
            UIActivityTypePostToTencentWeibo
        ]          self.navigationController!.presentViewController(activityViewController,
            animated: true,
            completion: nil)

Could this be an error from Xcode beta 7/iOS 9? Or am I missing something? Should I be worried about it?


回答1:


Either:

  1. This is an Apple bug - report it to https://feedbackassistant.apple.com/ as long as it's still in beta
  2. You present the modal from a oversized view controller (bug in frames?) and then the constraint V:[UIView:0x7c0a2fa0(<=528) breaks

Should you be worried?

  1. It won't cause crashes, but still it's a sign of a programmer error that the log is there, ideally you would provide priorities to constraints if you intentionally want to break them


来源:https://stackoverflow.com/questions/30954171/why-is-activityviewcontroller-displaying-auto-constraint-errors-in-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!