ZacharyKhan / ZKCarousel

A simple carousel implementation written in Swift
MIT License
289 stars 57 forks source link

Conflicting Constraint Errors #18

Closed MMooreGitHub closed 6 years ago

MMooreGitHub commented 6 years ago

Hi,

  1. I'm receiving the following message below when running the example app you provided. Both natively as well as ingested within my app. Also, it's important to note I updated my POD to the latest today and am running ZKCarousel (0.1.5)
  2. I setup a symbolic breakpoint and discovered that the offending code is:

ZKCarousel.swift extension UIView {

func **addConstraintsWithFormat**(_ format: String, views: UIView...) {

    var viewsDictionary = [String: UIView]()
    for (index, view) in views.enumerated() {
        let key = "v\(index)"
        viewsDictionary[key] = view
        view.translatesAutoresizingMaskIntoConstraints = false
    }

    **addConstraints(**NSLayoutConstraint.constraints(withVisualFormat: format, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDictionary))
}

}

Also: setup(){ self.addConstraintsWithFormat("V:[v0(43)]-[v1]", views: self.titleLabel, self.descriptionLabel) }

  1. I've tested against an iPhone Xs Max and iPhone 6s plus

Error Below: 2018-10-04 14:44:23.392251-0400 ZKCarousel_Example[459:44964] [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:0x2827c0a50 UILabel:0x105110440.bottom == UILabel:0x105118060.top + 8 (active)>", "<NSLayoutConstraint:0x2827c12c0 V:[UILabel:0x105110440]-(NSSpace(8))-[UILabel:0x105118060] (active)>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x2827c12c0 V:[UILabel:0x105110440]-(NSSpace(8))-[UILabel:0x105118060] (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. 2018-10-04 14:44:24.892541-0400 ZKCarousel_Example[459:44964] [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:0x2827d3520 UILabel:0x105215de0.bottom == UILabel:0x1052160d0.top + 8 (active)>", "<NSLayoutConstraint:0x2827d3c00 V:[UILabel:0x105215de0]-(NSSpace(8))-[UILabel:0x1052160d0] (active)>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x2827d3c00 V:[UILabel:0x105215de0]-(NSSpace(8))-[UILabel:0x1052160d0] (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. 2018-10-04 14:44:25.076927-0400 ZKCarousel_Example[459:44964] [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:0x2827c1680 UILabel:0x10510ddd0.bottom == UILabel:0x105104fa0.top + 8 (active)>", "<NSLayoutConstraint:0x2827d32a0

ZacharyKhan commented 6 years ago

Thanks for this, I will look into it shortly and confirm if it is a bug.

ZacharyKhan commented 6 years ago

I've made some changes, run pod update and make sure you are on ZKCarousel 0.1.9. This should fix your issue, but if it persists feel free to open another issue.

MMooreGitHub commented 6 years ago

Thanks, @ZacharyKhan

I'm still receiving the issue with the latest release (0.1.9). I'll open a new issue.