程式碼demo已在Github開源, MXRotationManager, 如果能幫助到您,請幫忙點個星star哈,謝謝!
MXRotationManager
一行程式碼控制iOS裝置旋轉方向UIInterfaceOrientationMask
螢幕截圖
UIDeviceOrientationLandscapeLeft | UIDeviceOrientationLandscapeRight |
---|---|
如何使用
在 AppDelegate.m
裡 實現 AppDelegate
代理方法
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [MXRotationManager defaultManager].interfaceOrientationMask;
}
複製程式碼
UIDeviceOrientationLandscapeLeft
[MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeLeft;
複製程式碼
UIDeviceOrientationLandscapeRight
[MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeRight;
複製程式碼