0

How do I resize a text view so that it expands when displayed in the new 4" screens that it isn't shorter? I'm using AutoLayout. Also, I calculated that since the iOS keyboard takes up 216 points on both devices, and since the Navigation bar takes up 44 points on both devices, that the remaining view would be 200 points on a 320x460 screen. But how do I set this relative to the iPhone 5 screen? Any help would be appreciated. I've provided a screenshot to illustrate what I mean to better understand my issue.

Normal Screen (Works great!):

iPhone 5 Screen (Not so great!):

jscs
  • 63,694
  • 13
  • 151
  • 195
Carpetfizz
  • 8,707
  • 22
  • 85
  • 146

3 Answers3

0

It is quite simple calculate height of textfield like this

CGFloat TextFieldHeight = self.view.frame.size.height - keyboardHeight- statusbarheight - navigationBarHeight;

Then assign this height to your textfield.

CGRect TextFieldNewFrame = textField.frame;
TextFieldNewFrame.size,height = TextFieldHeight;
textField.frame = TextFieldNewFrame;
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
  • Thanks! I've done this, but how do I actually assign it to my TextView properties, since they are readonly? I'm using `[[self htmlText]frame].size.height = textFieldHeight;` – Carpetfizz Jun 12 '13 at 02:01
  • textView frame is not a readonly property. You can create a CGRect then assign to textview frame. See my edited answer. – Rahul Vyas Jun 12 '13 at 11:57
0

Try do like this:

self.view.autoresizesSubviews = YES; self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

stosha
  • 2,108
  • 2
  • 27
  • 29
0

Just ended up disabling autolayout for that specific view controller, and set my own CGRect.

  CGRect largeScreen = CGRectMake(0, 1, 640, 290);
    CGRect screenBounds = [[UIScreen mainScreen]bounds];
    if (screenBounds.size.height==568)
    {
        [self.htmlText setTranslatesAutoresizingMaskIntoConstraints:YES];
        htmlText.frame = largeScreen;

    }
Carpetfizz
  • 8,707
  • 22
  • 85
  • 146