Latest 0.0.3
Homepage https://github.com/popor/PoporOrientation
License MIT
Platforms ios 8.0
Dependencies PoporFoundation/NSObject
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

1.you need registe in AppDelegate

1.你需要在 AppDelegate中注册

- (BOOL)application:(UIApplication *)application did finishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [PoporOrientation swizzlingAppDelegate:self];
    return YES;
}

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
    // this will be replaced by PoporOrientation within runtime, do not remove!
    return UIInterfaceOrientationMaskPortrait;
}

2. demo

- (void)autoRotationAction:(UIButton *)bt {
    bt.selected = !bt.isSelected;
    if (bt.isSelected) {
        [PoporOrientation enableAutoFinish:nil];
        [self closeLockEvent];
    }else{
        [PoporOrientation disable];
    }
}

- (void)lockAction:(UIButton *)bt {
    bt.selected = !bt.isSelected;
    [PoporOrientation share].lock = bt.isSelected;
}

- (void)autoFisrtLeftAction:(UIButton *)bt {
    bt.selected = !bt.isSelected;
    if (bt.isSelected) {
        [PoporOrientation enableRotateTo:UIInterfaceOrientationLandscapeLeft finish:nil];
        [self closeLockEvent];
    }else{
        [PoporOrientation disable];
    }
}

- (void)autoFisrtRightAction:(UIButton *)bt {
    bt.selected = !bt.isSelected;
    if (bt.isSelected) {
        [PoporOrientation enableRotateTo:UIInterfaceOrientationLandscapeRight finish:nil];
        [self closeLockEvent];
    }else{
        [PoporOrientation disable];
    }
}

- (void)autoPriorityLeftAction:(UIButton *)bt {
    bt.selected = !bt.isSelected;
    if (bt.isSelected) {
        [PoporOrientation enablePriorityLeftFinish:nil];
        [self closeLockEvent];
    }else{
        [PoporOrientation disable];
    }
}

- (void)autoPriorityRightAction:(UIButton *)bt {
    bt.selected = !bt.isSelected;
    if (bt.isSelected) {
        [PoporOrientation enablePriorityRightFinish:nil];
        [self closeLockEvent];
    }else{
        [PoporOrientation disable];
    }
}

- (void)closeLockEvent {
    if (self.lockBT.isSelected) {
        dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            self.lockBT.selected = YES;
            [self lockAction:self.lockBT];
        });
    }
}

Requirements

Installation

PoporOrientation is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'PoporOrientation'

Author

popor, [email protected]

License

PoporOrientation is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "PoporOrientation",
    "version": "0.0.3",
    "summary": "Support a simple rotation framework.",
    "homepage": "https://github.com/popor/PoporOrientation",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "popor": "[email protected]"
    },
    "source": {
        "git": "https://github.com/popor/PoporOrientation.git",
        "tag": "0.0.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "PoporOrientation/Classes/*.{h,m}",
    "dependencies": {
        "PoporFoundation/NSObject": []
    }
}

Pin It on Pinterest

Share This