I am new in iOS programming
.
In my application (ios + Objective-C + Auto resize)
I have UITextView
inside of UIView
. Initially height of UIView
is 50 and UITextView
is 30 at the bottom of screen.
What I want to do is, I want to change height of both components as user type some text, i.e y
and height
of both components will change.
I use below code but its not working properly.
- (void)textViewDidChange:(UITextView *)textView
{
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
CGRect viewFrame = _viewMsg.frame;
viewFrame.origin.y = viewFrame.origin.y - (newSize.height - 30.0);
viewFrame.size.height = viewFrame.size.height + (newSize.height - 30.0);
_viewMsg.frame = viewFrame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
textView.frame = newFrame;
}
Please explain me how dynamically resizing work with Auto Resize
.