We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmethod-signatures" - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (self.isForceLandscape) { //只支持横屏 return UIInterfaceOrientationMaskLandscape; } else { //支持竖屏 return UIInterfaceOrientationMaskPortrait; } } #pragma clang diagnostic pop + (AppDelegate *)sharedAppDelegate { return (AppDelegate *)[UIApplication sharedApplication].delegate; } - (void)yh_changeOrientationPortrait { AppDelegate *appdelegate= [AppDelegate sharedAppDelegate]; appdelegate.isForceLandscape = NO; [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 = UIInterfaceOrientationPortrait; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } } - (void)yh_changeOrientationLandscapeRight { AppDelegate *appdelegate= [AppDelegate sharedAppDelegate]; appdelegate.isForceLandscape = YES; [appdelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:UIApplication.sharedApplication.keyWindow]; if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; int val = UIInterfaceOrientationLandscapeRight; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } }
The text was updated successfully, but these errors were encountered:
547578e
No branches or pull requests
Base Info for this issue
1. How to reproduce the problem.
2. Please help me in this way.
3. Here is a Demo.
4. Here is my Debug log
The text was updated successfully, but these errors were encountered: