swift - change TextView height - iOS -


i have xib file tableview header cell want self size. inside xib, have text view want change height on button press. when btn pressed, textview's height should size fit text inside , when btn pressed again, should resize 2 lines of text.

enter image description here

i used these lines of code in btn action

    let contentsize = self.content.sizethatfits(self.content.bounds.size)     var frame = self.content.frame     frame.size.height = contentsize.height     self.content.frame = frame 

it expands textview textview overlaps elements below it. using 2 lines of code below self sizing header makes every thing worse , shows 2 lines of textview , cm, , others disappear.

    tableview.estimatedsectionheaderheight = 115.0     tableview.sectionheaderheight = uitableviewautomaticdimension 

how can solve this?

it's possible using autolayout + uitableviewautomaticdimension, check out: http://candycode.io/self-sizing-uitextview-in-a-uitableview-using-auto-layout-like-reminders-app/


Comments