Iphone: resize image when rotating device

I am trying to develop an application that is geosensitive. So I wrote -

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    // return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
}

      

I have placed different images on this screen and I have to resize it when the view changes. So what can I do?

0


a source to share


3 answers


-shouldAutorotateToInterfaceOrientation: This is a method in the UIViewController that will cause its view to resize when the device orientation changes.

You have two main approaches to resizing the subviews of this view:



1) You can customize the autoresizingMask for this view so that they resize when their supervisor resizes. If you add subviews using Interface Builder, you can set these masks visually from the Size panel.

2) You can override -layoutSubviews in this view and change them manually in this method.

+1


a source


imageViewObject.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | 
                                   UIViewAutoresizingFlexibleRightMargin | 
                                   UIViewAutoresizingFlexibleTopMargin | 
                                   UIViewAutoresizingFlexibleBottomMargin |
                                   UIViewAutoresizingFlexibleHeight |
                                   UIViewAutoresizingFlexibleWidth;

      



+1


a source


You can resize your view in - (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation duration: (NSTimeInterval) duration method eg:

  • (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation duration: (NSTimeInterval) duration {

    if ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) {

    } yet {

    }

}

+1


a source







All Articles