I need to change UITextView Frame height dynamically with respect to content height of it. i.e. so when ever contain height is increased rather than allowing user to scroll i would like to change my UITextView's Frame height so users can read all data.
So here i my code snipper,
-(void)viewDidLoad{
[super viewDidLoad];
_txtView.delegate = self;
previousheight = _txtView.contentSize.height;
NSLog(@"%.2f",previousheight);
}
Here i am getting log value -> 22.
-(void)textViewDidChange:(UITextView *)textView{
NSLog(@"%.2f",textView.contentSize.height);
}
Here i am getting log value -> 36.
===============================================================================
Now another way, if i disable scrolling of UITextView then i am getting perfect/expected result. Only thing is i am not able to enable scrolling afterward.
-(void)viewDidLoad{
[super viewDidLoad];
_txtView.scrollEnabled = FALSE;
previousheight = _txtView.contentSize.height;
NSLog(@"%.2f",previousheight);
}
Here i am getting log value -> 30.
-(void)textViewDidChange:(UITextView *)textView{
NSLog(@"%.2f",textView.contentSize.height);
txtView.scrollEnabled = TRUE;
}
Here i am getting log value -> 30.
But now there are no scrolling, although i have enable scrolling view.
Any help would be appreciated. Thanks