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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to