-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2b7345a
commit 547578e
Showing
11 changed files
with
129 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// CYLTabBarController.h | ||
// CYLTabBarController | ||
// | ||
// v1.21.x Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15. | ||
// Copyright © 2018 https://github.com/ChenYilong . All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSObject (CYLLandscapeExtension) | ||
|
||
@property (nonatomic, assign, getter=cyl_isForceLandscape, setter=cyl_setIsForceLandscape:) BOOL cyl_isForceLandscape; | ||
|
||
- (void)cyl_forceUpdateInterfaceOrientation:(UIInterfaceOrientation)orientation; | ||
|
||
- (UIResponder<UIApplicationDelegate> *)cyl_sharedAppDelegate; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// CYLTabBarController.h | ||
// CYLTabBarController | ||
// | ||
// v1.21.x Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15. | ||
// Copyright © 2018 https://github.com/ChenYilong . All rights reserved. | ||
// | ||
|
||
#import "NSObject+CYLLandscapeExtension.h" | ||
#import <objc/runtime.h> | ||
|
||
@implementation NSObject (CYLLandscapeExtension) | ||
|
||
- (BOOL)cyl_isForceLandscape { | ||
NSNumber *isForceLandscapeObject = objc_getAssociatedObject(self, @selector(cyl_isForceLandscape)); | ||
return [isForceLandscapeObject boolValue]; | ||
} | ||
|
||
- (void)cyl_setIsForceLandscape:(BOOL)isForceLandscape { | ||
NSNumber *isForceLandscapeObject = @(isForceLandscape); | ||
objc_setAssociatedObject(self, @selector(cyl_isForceLandscape), isForceLandscapeObject, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
- (UIResponder<UIApplicationDelegate> *)cyl_sharedAppDelegate { | ||
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate; | ||
return (UIResponder<UIApplicationDelegate> *)appDelegate; | ||
} | ||
|
||
- (void)cyl_forceUpdateInterfaceOrientation:(UIInterfaceOrientation)orientation { | ||
UIResponder<UIApplicationDelegate> *appDelegate = [self cyl_sharedAppDelegate]; | ||
BOOL isForceLandscape = (UIInterfaceOrientationLandscapeLeft == orientation) || (UIInterfaceOrientationLandscapeRight == orientation); | ||
appDelegate.cyl_isForceLandscape = isForceLandscape; | ||
if ([appDelegate respondsToSelector:@selector(application:supportedInterfaceOrientationsForWindow:)]) { | ||
[appDelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:UIApplication.sharedApplication.keyWindow]; | ||
} | ||
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { | ||
NSNumber *num = [[NSNumber alloc]initWithInt:UIInterfaceOrientationPortrait]; | ||
[[UIDevice currentDevice] performSelector:@selector(setOrientation:)withObject:(id)num]; | ||
[UIViewController attemptRotationToDeviceOrientation]; | ||
SEL selector = NSSelectorFromString(@"setOrientation:"); | ||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; | ||
[invocation setSelector:selector]; | ||
[invocation setTarget:[UIDevice currentDevice]]; | ||
int val = orientation; | ||
[invocation setArgument:&val atIndex:2]; | ||
[invocation invoke]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters