Search code examples
ioscocoauiviewuiimageviewcontentmode

Scale UIImageView after orientation changed


In my application i have UIIMageView within UIView, in portrait mode imageview fills whole area of UIView, but after orientation is changed UIView rotates but not stretched, though i have set content mode of UIView to Scale to fill, what is wrong?


Solution

  • Set the autoresizing mask:

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

    read also this.