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
标签:ViewController,void,iOS,selector,invocation,横屏,错乱,UIApplication,view 来源: https://blog.csdn.net/saw471/article/details/110655930