views:

347

answers:

3

I haven't been able to figure this out. Could someone please help me? I am trying to stop one UIView in my app from rotating when the device is turned.

I am working on a drawing app. Right now, when the device is turned, all UI elements turn with it. What I am trying to do is have all the buttons, menus, etc. turn, but have my canvas UIView be static and ignore the rotation of the phone.

+1  A: 

If the canvas view is a subview of a view that rotates, then it will rotate as well. It's inescapable.

If you have one element of a view that you do not want to appear to rotate, you have use a rotation transform to programmatically rotate that one view back to the orientation and frame you want it have.

TechZen
+1  A: 

You could use the following to prevent the view itself from rotating:

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
      return false;
}

Then manually rotate the individual elements you want rotated.

MHarrison
A: 

OP here. Rotating the view using CGAffineTransformMakeRotate() worked like a charm. Thanks, TechZen!

carloe