开发者

Ipad, can I detect device rotation without using view controllers?

开发者 https://www.devze.com 2023-01-05 08:46 出处:网络
I am making an Ipad app and im not using the views and view contr开发者_运维百科ollers (Except to call my own openGl drawing funcitons)

I am making an Ipad app and im not using the views and view contr开发者_运维百科ollers (Except to call my own openGl drawing funcitons)

I want the app to be able to change its drawing orientation depending on how the device is held. However with the research that ive done all I can find is how to do it through view controllers and accelerometers.

Is there a way to do it without going through all the overhead of using those, or am I out of luck?

If there is please point me in the right direction.

Thank you in advance.


Wow, I found exactly what I was looking for right after I posted the question.

But if anybody is wondering heres and easy way to figure out the general orientation of the device.

First you need to set up the UIDevice interface to detect orientation with:

[[UIDevice currentDevice] beginGeneratingDeviceOrientaionNotifications];

Then I believe there are several different ways of processing what it does but I just needed something simple so I add this code in my update loop:

UIDeviceOrientation curOrientation = [[UIDevice currentDevice] orientation];

And that gives you the orientation of the device! Easy!

0

精彩评论

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