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. :

center y leading space

then image, want set in center y of it's container , set ratio 1:1 on it. :

center y aspect ratio

note might want check width , height if don't want image upscale (if set bigger cell on device).

you should have :

storyboard

and result :

screen

let me know if helped.

ps : don't have image i've set background color on uiimageview


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -