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. constraint reference outside subtree of view? that's illegal.
as see, need create custom cell class, have constraint iboutlet
property nib file. can remove , add new leading space constraint.
Comments
Post a Comment