Pooja
Pooja

Reputation: 2200

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

Upvotes: 1

Views: 322

Answers (2)

Pacu
Pacu

Reputation: 1985

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
    }
    }
    

Upvotes: 2

Hanuman
Hanuman

Reputation: 642

yes you can change the size of the uitextfied by using its "frame" property

    txtField.frame = CGRectMake(0, 0, 400, 31);

based on the condition of the device orientation change the size

Upvotes: 0

Related Questions