PoporRotate 1.5

PoporRotate 1.5

popor 维护。



  • 作者:
  • popor

PoporRotate

CI Status Version License Platform

示例

要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install 命令。

要求

安装

PoporRotate 可通过 CocoaPods 安装。要安装,只需将以下行添加到 Podfile 中:

pod 'PoporRotate'

推荐用法

#import <PoporRotate/PoporRotate.h>
// XxxxAppDelegate
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
#if TARGET_OS_MACCATALYST
    return UIInterfaceOrientationMaskPortrait;
#else
    PoporRotate * pr = [PoporRotate share];
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        return pr.supportedInterfaceOrientations;
    } else {
        if (pr.appLoaded) {
            return pr.supportedInterfaceOrientations;
        } else {
            return UIInterfaceOrientationMaskPortrait;
        }
    }
#endif
}

// XxxxVC
self.pr = [PoporRotate share];
self.pr.appLoaded = YES;
- (void)vcAction:(NSInteger)tag {
    switch (tag) {
        case 0: {
            [self.pr orientationAll];
            break;
        }
        case 1: {
            [self.pr orientationLeft];
            break;
        }
        case 2: {
            [self.pr orientationRitht];
            break;
        }
        case 3: {
            //[self.pr orientationLandscape_priorityLeft:YES]; // 等同于下面
            [self.pr orientationAll_priority:UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight high:UIInterfaceOrientationMaskLandscapeRight];
            break;
        }
        case 4: {
            //[self.pr orientationLandscape_priorityLeft:NO]; // 等同于下面
            [self.pr orientationAll_priority:UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight high:UIInterfaceOrientationMaskLandscapeLeft];
            break;
        }
        case 5: {
            [self.pr orientationUp];
            break;
        }
        case 6: { // 手边没iPad没有测试
            [self.pr orientationVertical_priorityUp:YES];
            break;
        }
        case 7: { // 手边没iPad没有测试
            [self.pr orientationVertical_priorityUp:NO];
            break;
        }
        default:
            break;
    }
}

作者

popor, [email protected]

许可证

PoporRotate可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。