Skip to content
New issue

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

使用这个框架后代码强制横屏失败 #60

Open
Jijingcheng opened this issue Apr 21, 2021 · 1 comment
Open

使用这个框架后代码强制横屏失败 #60

Jijingcheng opened this issue Apr 21, 2021 · 1 comment

Comments

@Jijingcheng
Copy link

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
// 打开横屏开关
appDelegate.allowRotation = YES;
// 调用转屏代码
[UIDevice deviceMandatoryLandscapeWithNewOrientation:UIInterfaceOrientationLandscapeRight];

/// 输入要强制转屏的方向
/// @param interfaceOrientation 转屏的方向

  • (void)deviceMandatoryLandscapeWithNewOrientation:(UIInterfaceOrientation)interfaceOrientation {

    NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];

    [[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];

    // 将输入的转屏方向(枚举)转换成Int类型
    int orientation = (int)interfaceOrientation;

    // 对象包装
    NSNumber *orientationTarget = [NSNumber numberWithInt:orientation];

    // 实现横竖屏旋转
    [[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
    }

@yiplee
Copy link
Owner

yiplee commented Oct 15, 2021

这个库没有涉及到屏幕的方向

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants