代码demo已在Github开源, MXRotationManager, 若是能帮助到您,请帮忙点个星star哈,谢谢!git
MXRotationManager
一行代码控制iOS设备旋转方向UIInterfaceOrientationMask
github
UIDeviceOrientationLandscapeLeft | UIDeviceOrientationLandscapeRight |
---|---|
![]() |
![]() |
在 AppDelegate.m
里 实现 AppDelegate
代理方法bash
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [MXRotationManager defaultManager].interfaceOrientationMask;
}
复制代码
[MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeLeft;
复制代码
[MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeRight;
复制代码