[iPhone] How to scale a UITextView Properly with typing text shown
[iPhone] How to scale a UITextView Properly with typing text shown
- Subject: [iPhone] How to scale a UITextView Properly with typing text shown
- From: Tharindu Madushanka <email@hidden>
- Date: Thu, 20 May 2010 19:15:48 +0530
I use following code in UITextView Delegate method to resize the text view.
I want it to look like iPhone Messages.
Still this doesn't show the already typed text on top. I mean it doesn't
scroll to the correct typing position in text view. Could anyone kindly
correct this code ? To scroll the text view properly to typing text when
scaling.
- (void)textViewDidChange:(UITextView *)textView {
CGSize textSize = [textview.text sizeWithFont:textview.font
constrainedToSize:textview.contentSize
lineBreakMode:UILineBreakModeWordWrap];
int rtxtHeight = textview.contentSize.height - 16.0f;
int noOfLines = rtxtHeight / 21;
NSLog(@"No Of Lines: %d content:%f", noOfLines,
textview.contentSize.height);
CGRect tbframe = tableview.frame;
float changeHeight = rtxtHeight + 16.0f;
CGRect tframe = textview.frame;
NSLog(@"[MessageViewController] change:%f
contentHeight:%f",changeHeight, textSize.height);
if (changeHeight != tframe.size.height && noOfLines > 0 && noOfLines <
5) {
if (tframe.size.height > changeHeight) {
tframe.origin.y += 21.0f;
tbframe.size.height += 21.0f;
} else {
tframe.origin.y -= 21.0f;
tbframe.size.height -= 21.0f;
}
tframe.size.height = changeHeight;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.3f];
tableview.frame = tbframe;
textview.frame = tframe;
//textview.frame = tframe;
[UIView commitAnimations];
}
}
Tharindu
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden