4

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.

MobileOverlord
  • 4,580
  • 3
  • 22
  • 30

2 Answers2

0

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

self.appContainer.transform = CGAffineTransformIdentity;
  • this doesn't work because the view's transformation is being modified by the device rotation event. By setting it back to identity I am getting the same results. After the device rotation event, the view's transformation needs to be taken to .8 scale of that orientation. – MobileOverlord May 09 '12 at 16:15
0

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

[self.appContainer setAutoresizingMask:UIViewAutoresizingNone];
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76