0
votes

I'm trying to modify the frame of a UIImageView when a specific rotation happens, but when i change it the UIImage inside the UIImageView doesn't look affected, and if i NSLog the UIImageView frame size its changed, but its not reflected on the view, why this happens?

@property (strong, nonatomic) IBOutlet UIImageView *couponBg;

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
     if ((UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) &&
         UIDeviceOrientationLandscapeRight == [[UIDevice currentDevice] orientation])         {
         self.couponBg.frame = CGRectMake(0, 0, self.couponBg.frame.size.width, self.couponBg.frame.size.height);
         NSLog(@"FRAME:%@", NSStringFromCGRect(self.couponBg.frame));
         self.couponBg.frame = CGRectZero;
         NSLog(@"FRAME:%@", NSStringFromCGRect(self.couponBg.frame));
     }
 }

I get the correct frame sizes in NSLog:

2013-11-23 17:05:00.674 -----[10302:70b] FRAME:{{0, 0}, {320, 199}}

2013-11-23 17:05:00.674 -----[10302:70b] FRAME:{{0, 0}, {0, 0}}

But in the view the Image is always the same size ? Why is this happening?

2
I think the most likely culprit is that you haven't actually assigned the UIImageView that has been added to your view to self.couponBg Can you verify that you have done this?Adam

2 Answers

0
votes

This is taken from apple UIView documentations:

autoresizesSubviews A Boolean value that determines whether the receiver automatically resizes its subviews when its bounds change. @property(nonatomic) BOOL autoresizesSubviews When set to YES, the receiver adjusts the size of its subviews when its bounds change. The default value is YES.

You should make sure this value is set up in your UIImageView and you should set your UIImage.autoresizingMask to right value.

0
votes

The problem was related to the CGATransform and Autolayout when i did the rotation.