How do I size a UITextView to its content on iOS 7?

前端 未结 13 1816
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 03:04

I\'ve been using the accepted answer here for years.

On iOS 7, the contentSize.height becomes the frame.height-8, regardless of text content.

What\'s a worki

13条回答
  •  抹茶落季
    2020-11-28 03:48

    Guys using autolayout and your sizetofit isn't working, then please check your width constraint once. If you had missed the width constraint then the height will be accurate.

    No need to use any other API. just one line would fix all the issue.

    [_textView sizeToFit];
    

    Here, I was only concerned with height, keeping the width fixed and had missed the width constraint of my TextView in storyboard.

    And this was to show up the dynamic content from the services.

    Hope this might help..

提交回复
热议问题