3

I use a UITextView in my app and I set it's frame based on the size of the text. However, if the UITextView.size.height is greater than 8192.0, the text just disappears.

Does UITextView have a maximum height?

EDIT

I appreciate all the answers so far, but I'm already able to set the frame with no problem. The problem is that, if the frame.size.height is set greater than 8192.0, the text just completely disappears.

I'm not sure what's special about that number, but when I set the frame with a height greater than that number, it stops working.

Cody Winton
  • 2,989
  • 5
  • 25
  • 48
  • 1
    Possible duplicate of [UITextView text becomes invisible after height reaches 8192.0](http://stackoverflow.com/questions/23582497/uitextview-text-becomes-invisible-after-height-reaches-8192-0) – Fateh Khalsa May 17 '16 at 17:05

3 Answers3

1

Check the documentation https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html

Note: In iOS 2.x, the maximum size of a UIView object is 1024 x 1024 points. In iOS 3.0 and later, views are no longer restricted to this maximum size but are still limited by the amount of memory they consume. It is in your best interests to keep view sizes as small as possible. Regardless of which version of iOS is running, you should consider tiling any content that is significantly larger than the dimensions the screen.

It seams that it is a memory problem and not a specific height

Hani Ibrahim
  • 1,448
  • 11
  • 21
  • That does sound possible. So, how do I tile my content in the `UITextView`? – Cody Winton Dec 04 '13 at 19:35
  • This Quotation was on UIView that is the superView of the UITextView ... So Tiling in UIView may be made with UITableView for example ... But I don't know in your case what you can do – Hani Ibrahim Dec 05 '13 at 11:13
-1
- (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;
}
Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38
Sowji
  • 35
  • 1
  • 8
-1

Use below code

CGSize titlesize = [TxtValue.text sizeWithFont:[UIFont fontWithName:@"Helvetica" size:15.0f] constrainedToSize:CGSizeMake(UITextView.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];

UITextView.frame=CGRectMake(TxtValue.frame.origin.x, TxtValue.frame.origin.y, TxtValue.frame.size.width, titlesize.height);
Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38