ios - Swift - edit contraints on the last cell from UICollection View -
i edit contraint last cell uicollectionview. in cell have image contraints on center of cell want align left of cell. i trying it: let cell : mycellcollection = collectionview.dequeuereusablecellwithreuseidentifier("mycellcollection", forindexpath: indexpath) as! mycellcollection var oldrole : nslayoutconstraint = nslayoutconstraint(item: cell.imageview1, attribute: nslayoutattribute.centerx, relatedby: nslayoutrelation.equal, toitem: cell, attribute: nslayoutattribute.centerx, multiplier: 1, constant: 0) var newrole : nslayoutconstraint = nslayoutconstraint(item: cell.imageview1, attribute: nslayoutattribute.leading, relatedby: nslayoutrelation.equal, toitem: cell, attribute: nslayoutattribute.leading, multiplier: 1, constant: 8); cell.imageview1.removeconstraint(oldrole) cell.imageview1.addconstraint(newrole) when run got error: terminating app due uncaught exception 'nsgenericexception', reason: 'unable install constraint on view. constrain