Search code examples
iphoneobjective-cuiviewuitextfieldautosize

uitextfied autosize for Landscape if it before in Portrait view


i don't know about this:

is it possible that if user switch to Landscape view then size of uitextfied change as i have 4 text file in view ....just look and feel


Solution

  • If you are using IB you have two ways of doing it.

    1. using the auto resize properties in object inspector of Interface Builder. That will resize your textfields automatically.

    2. If that does not suffice your needs, you will have to control that in your ViewController method

      -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation  {
      if (UIInterfaceOrientationIsPortrait (fromInterfaceOrientation)) {
          txtField.frame = CGRectMake(0, 0, 400, 31);
      }
          else {
              //orientation for portrait
      }
      }