iOS UITextView sizeToFit make height doubled of content text in iPad

35 views Asked by At

Below is my code of textView, but sizeToFit makes textView's height more than doubled of it's content text. Please provide any solution

UITextView *paragraphView  = [[UITextView alloc] initWithFrame: CGRectMake(10, 10, 295, 30)];
[paragraphView setContentMode: UIViewContentModeScaleToFill];
[paragraphView setScrollEnabled: NO];
[paragraphView setEditable: NO];
[paragraphView setText: @"hello there ..........hii i am here....."];
[paragraphView setFont: [UIFont systemFontOfSize: 30]];

[self.view addSubview: paragraphView];

[paragraphView sizeToFit];
1

There are 1 answers

0
Jerry On

Try using NSLayout constraints to frame the UITextview instead of initwithframe. you may get the content sized height for textview properly