swift - iOS8 UITableViewCell with ImageView autolayout cell stretch -
i trying implement autolayout on tableview in ios 8 swift , have cell holds image automatically enlarges fit image in correct aspect ratio(aspect fit). can if select image image picker , display picture properly. if open app , expect image show same, shows tiny square. know it's constraints not being set right can figure out issue lies. console complaining constraints well. see pictures , code i'm using.
link looks like: http://i.stack.imgur.com/5jsbv.png
link constraints setup: http://i.stack.imgur.com/q5xcr.png
and code use control image aspect:
func showimage(image: uiimage) { let aspect = image.size.width / image.size.height aspectconstraint = nslayoutconstraint(item: imageview, attribute: nslayoutattribute.width, relatedby: nslayoutrelation.equal, toitem: imageview, attribute: nslayoutattribute.height, multiplier: aspect, constant: 0.0) imageview.image = image imageview.hidden = false addphotolabel.hidden = true }
your side edge constraints what's messing up. remove those, , instead apply aspect ratio constraint. if force margins on 1 axis (top/bottom or left/right), scale image proportionally fit.
Comments
Post a Comment