iOS 横屏启动时页面错乱解决方案
程序员文章站
2022-03-13 21:41:18
在控制器调用恢复状态栏事件#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self restoreStatusBarOrientation];}...
在控制器调用恢复状态栏事件
#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
本文地址:https://blog.csdn.net/saw471/article/details/110655930
下一篇: 常见 MIME 类型列表