swift - How to add constraints to a Custom UITableViewCell -
i have created custom cell table view , works fine except image view not align correctly.
is there way add constraints custom cell view? programmatically or otherwise?
this cell looks in storyboard - hoping achieve @ run time:
but when demo app happens:
here image storyboard:
view controller /w tableview
@iboutlet weak var tableview: uitableview! override func viewdidload() { super.viewdidload() println(questions) println(finalresults) let thewidth = view.frame.size.width let theheight = view.frame.size.height tableview.frame = cgrectmake(0,0, theheight, thewidth) }
cell view controller
override func awakefromnib() { let thewidth = uiscreen.mainscreen().bounds.width contentview.frame = cgrectmake(0,0, thewidth, 64) answerimage.center = cgpointmake(115, 15) }
you have set constraints correctly. indeed, if add missing constraints
, reset suggested constraints
handy don't know want, result cannot expect.
what might want here following.
for question label set in center y of it's container , set it's leading space superview. :
then image, want set in center y of it's container , set ratio 1:1 on it. :
note might want check width
, height
if don't want image upscale (if set bigger cell on device).
you should have :
and result :
let me know if helped.
ps : don't have image i've set background color on uiimageview
Comments
Post a Comment