forkingdog / UITableView-FDTemplateLayoutCell

Template auto layout cell for automatically UITableViewCell height calculating
MIT License
9.93k stars 2.01k forks source link

Contraints leads to conflicts #47

Open confile opened 9 years ago

confile commented 9 years ago

I used it on the collapse table view example Apple provided here:

https://developer.apple.com/library/ios/samplecode/TableViewUpdates/Introduction/Intro.html

I used the not cached version of this plugin. When I click on a section header to open the rows in the section then I get the following error:

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) 
(
    "<_UIScrollViewAutomaticContentSizeConstraint:0x7a09e6a0 UITableView:0x7c1d4400.contentHeight{id: 178} == -5.000000>"
)

Will attempt to recover by breaking constraint 
<_UIScrollViewAutomaticContentSizeConstraint:0x7a09e6a0 UITableView:0x7c1d4400.contentHeight{id: 178} == -5.000000>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

My Custom Cell looks like this:

class MyCell: UITableViewCell {

   override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
      super.init(style: style, reuseIdentifier: reuseIdentifier)
      setupView()
   }

   private func setupView() {
      let addButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton 
      self.contentView.addSubview(addButton)
      addButton.snp_makeConstraints { (make) -> Void in
          make.edges.equalTo(self.contentView).priorityLow()
      }
  }
}

How can I fix this issue?

confile commented 9 years ago

To make autolayout in code I use: https://github.com/SnapKit/SnapKit