ios - Fix the aspect ratio of the first row in UITableView -


i'm creating screen, imagine facebook profile screen.. tableview , first cell image. goal image maintains aspect ratio, different screen sizes don't have worry sizing it..

i can't work view, if set specific constraints, cell won't set correct height..

i have little project showing constraints, in link..

my vc code:

class viewcontroller: uitableviewcontroller{      override func viewdidload() {         super.viewdidload()         self.tableview.datasource = self         self.tableview.delegate = self         self.tableview.estimatedrowheight = 100         self.tableview.rowheight = uitableviewautomaticdimension          self.tableview.reloaddata()     }      override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath)         return cell     }      override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {         return 1     } } 

my constrains: enter image description here

if height of table view cell function of table view's width, might easier implement heightforrowatindexpath delegate method return width of table view multiplied ratio want. take constraints out of picture entirely, , more efficient.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -