4
votes

I have a view that I am performing a transform on

originalTransform = self.appContainer.transform;
self.appContainer.transform = CGAffineTransformMakeScale(.8, .8);

Original Rotation

If I do not rotate the device I can revert this back to the original by using

self.appContainer.transform = CGAffineTransformScale(originalTransform, 1, 1);

Unfortunately, if I rotate the device, the transformation matrix for the view gets modified by the view rotation and breaks the original scale. If I undo the scale after rotation I am left with the UIView not returning to its original full size.

After Rotation

After Original Scale

I'm sure that I need to make calculations between the original transformation matrix and the new one but I am unsure how to do this. The only thing I have been able to do to make this work is to revert the scale back to 1 before rotation

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    self.appContainer.transform = CGAffineTransformScale(originalTransform, 1, 1);
}

And then rescale it with the newly modified transformation after the

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation               {
    self.appContainer.transform = CGAffineTransformMakeScale(.8, .8);
}

This makes it work as I expect, but instead of going back to full screen, and then back to .8 scale, I'd like it to go from its new transformation to the correct .8 scale.

2
Have you finally handled this? I'm looking for solution.Krzysztof Przygoda
I'm looking for solution too..Pipiks

2 Answers

0
votes

If you want to revert it to original, try setting the transform to CGAffineTransformIdentity.

self.appContainer.transform = CGAffineTransformIdentity;
0
votes

I think you have to remove all autoresizing masks using.....

[self.appContainer setAutoresizingMask:UIViewAutoresizingNone];