• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[iPhone] How to scale a UITextView Properly with typing text shown
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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

  • Prev by Date: Re: Regarding MVC design pattern
  • Next by Date: Re: Simulating Text Input
  • Previous by thread: Re: NSData from CGPDFPageRef
  • Next by thread: Binding CoreData Managed Object to NSTextFieldCell subclass
  • Index(es):
    • Date
    • Thread