ios - heightForRowAtIndexPath Not working properly -


i trying display image correct aspect ratio in tableview. have pre-calculated aspect ratio of image, , seems work on actual image, not on cell displayed in.

code image in cell:

private var cellimage: uiimage? {         { return cellimageview.image }         set {             cellimageview?.image = newvalue             if let newimage = newvalue {                 heightconstraint.constant = newimage.size.width / cgfloat(aspectratio)             }         }     } 

code in tableview:

override func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat {             return tableview.bounds.size.width / cgfloat(aspectratio)     } 

aspectratio variable same in both. aspectration = width/height of image. also, checked see height received in both places same, , same value (in runtime).

anyone know why cell height not set correctly?

you can use dynamic cell height , make cell fit imageview inside check tutorial https://www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -