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

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

#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

 

上一篇:Flutter-现有iOS工程引入Flutter


下一篇:iOS技术沙龙之:创建第一款iPhone应用程序