PoporOrientation
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
1.需要在 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.演示
- (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];
});
}
}
要求
安装
PoporOrientation 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'PoporOrientation'
作者
popor, [email protected]
许可证
PoporOrientation 适用于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。