Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在做一个射击游戏。屏幕中间有一个靶心和一个由加速度计控制的十字准线。我想检查用户是水平还是垂直控制设备。当用户垂直握住它时,我不希望十字准线向下滚动。只有当我垂直或水平倾斜我的设备时,十字准线才会移动。任何人?
可能有用,您是否尝试过使用 compass api 呢?
你试过这个吗?:
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
然后:
if (UIDeviceOrientationIsLandscape(orientation)) { } else if (UIDeviceOrientationIsPortrait(orientation)) { }