开发者

iPhone - Prohobit UIView from rotating when the device is turned

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 canva开发者_如何学运维s UIView be static and ignore the rotation of the phone.


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜