Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to change size of UITEXTVIEW according to its text ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 463
    Comment on it

    To change the size of a UITextView to its contents i.e as the content of the UITextView increases the size of the textview will also increase.
    We can implement this by applying the following code :-

    - (void)textViewDidChange:(UITextView *)textView
    {
        CGFloat fixedWidth = textView.frame.size.width;
        
        CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
        
        CGRect newFrame = textView.frame;
        
        newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
       
         textView.frame = newFrame;
    }

    Remember we have to set the delegate of UITextView also..

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: