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.
我有一个特定的视图控制器,我希望这样做:加载时,如果设备是横向的,则显示横向但不自动旋转。加载时,如果设备为纵向,则显示纵向但不自动旋转。我找不到合适的解决方案,有人可以建议吗?
尝试检查viewWillAppear()上的方向,然后根据方向设置视图以您想要的方式显示。
int orientationType = [[UIDevice currentDevice] orientation];
1 = 纵向 2 = 纵向(倒置) 3 = 横向(右) 4 = 横向(左)
要在视图上禁用自动旋转:
- (BOOL) shouldAutorotate { return NO; }