用户登录
用户注册

分享至

iOS 横屏启动时页面错乱解决方案

  • 作者: 擼人甲
  • 来源: 51数据库
  • 2021-06-27

在控制器调用恢复状态栏事件

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self restoreStatusBarOrientation];
}

/// 恢复状态栏样式
- (void)restoreStatusBarOrientation
{
    SEL selector = @selector(setStatusBarOrientation:);
    if ([[UIApplication sharedApplication] respondsToSelector:selector])
    {
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIApplication instanceMethodSignatureForSelector:selector]];
        UIDeviceOrientation orentation = UIDeviceOrientationPortrait;
        [invocation setSelector:selector];
        [invocation setTarget:[UIApplication sharedApplication]];
        [invocation setArgument:&orentation atIndex:2];
        [invocation invoke];
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

?

软件
前端设计
程序设计
Java相关