0

In my table view cell I have

var myAnchor: NSLayoutConstraint?

    let myAnchor = myView.widthAnchor.constraint(equalToConstant: screenWidth / 6).isActive = true

Then in my table view cellForRowAt function I have

if indexPath.row == myArray.count - 1 {

        cell.myAnchor!.constant = 0
    }

This compiles but crashes with unexpectedly found nil. I want to change the width of the view to 0 for the last row. I can get this done by setting isHidden = true but that causes constraint warnings and obviously isn't right. I have also tried setting isActive = false but that doesn't work either.

markhorrocks
  • 1,199
  • 19
  • 82
  • 151

0 Answers0