CGAffineTransformRotate in viewDidLoad stretches / increases UIImageView

I need to rotate the UIImageView created by the interface designer when loading the view.

- (void)viewDidLoad { [super viewDidLoad]; image.transform = CGAffineTransformRotate(image.transform, REF_INIT_OFFSET*M_PI/180); } 

This rotates the image, but the latter is completely distorted and stretched. If REF_INIT_OFFSET is a multiple of 90, it works great!

Here's what the image should look like (note the needle pointing to "0")

enter image description here

and this is how it actually looks:

it looks like the image is stretched in the wrong direction.

Do you have an idea what's wrong?

thanks,

+4
source share
1 answer

Not sure if it will help you, but I had the same problem after [UIImage setFrame:], if UIImage was converted, the solution used setBounds instead of setFrame

Solving the problem when discussing in the comments:

The setFrame method is called after viewDidLoad in shouldAutorotateToInterfaceOrientation implicitly if the autoresizesSubviews property is YES

 - (void)viewDidLoad { [super viewDidLoad]; self.view.autoresizesSubviews=NO; image.transform = CGAffineTransformRotate(image.transform, 50*M_PI/180); } 
+7
source

All Articles