-2

[last]1 [last]2

I was trying to add constraint to my repeatSegment.

    //Repeat Segment
        repeatSegment?.setNeedsDisplay()

        repeatSegment?.translatesAutoresizingMaskIntoConstraints = false
        let repeatSegmentConstraint1 = NSLayoutConstraint(item: repeatSegment!, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.00, constant: 190) <<Error here

1 Answers1

0

As can be seen in the comments above there was two problems here.

  1. self could not be used as a parameter to toItem. In this case self was a UIViewController which caused the error. To fix this, view was used instead.

  2. As can be seen in this answer the constraint must be added to the superView instead of the child, in this case to view instead of songSlider.

Community
  • 1
  • 1
pbodsk
  • 6,787
  • 3
  • 21
  • 51