ios - Autogrowing UITextView inside UITableView cell -


i have static uitableview , 1 of cell contains text view , want make text view autogrowable, , make cell grow @ same time. wrapping text instead of cutting it.

in isoalted text view dont face issue due have fixed size , show long texts have scroll inside textview, in case doesnt want scroll, uitextview set nonscrolable because parent (uitableview) have scroll , want avoid nested scrolls.

my approach sort out overrayde height.... , reload view every time user types using sizethatfits(size: cgsize) know requerid size, , set uitextview cell size, , show text correctly.

but cell grows bit, , not enough, researched sizethatfits know if understand it, method mesure of object fit inside objets, or there other parameters care paddings, margins, or constriant , i'm not able find things explained.

then have questions, did missunderstood method? how shoud use it? in correct path reach goal? or there better way it?

thank much.

override func tableview(tableview: uitableview,                heightforrowatindexpath indexpath: nsindexpath) -> cgfloat {      let defaulheight: cgfloat = 44      if indexpath.row == textfieldrownumber {         let cellsize = messagetableviewcell.bounds.size         let wantedsize = longmessagetextfield.sizethatfits(cellsize)             return wantedsize.height     } else {         return defaulheight     } }   func textview(textview: uitextview, shouldchangetextinrange  range: nsrange, replacementtext text: string) -> bool {     textview.resignfirstresponder()     let previousmessageinput = longmessagetextfield.text     longmessagetextfield.text = previousmessageinput! + text      let indextoreload = nsindexpath(foritem: 4, insection: 0)     self.tableview.reloadrowsatindexpaths([indextoreload], withrowanimation: uitableviewrowanimation.top)             return true } 

did try reading textview's contentsize property, instead of calling sizethatfits?


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -