1. 程式人生 > >iOS之修復手機橫屏啟動介面錯亂

iOS之修復手機橫屏啟動介面錯亂

- (void)restoreStatusBarOrientation {
    if ([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarOrientation:)]) {
        SEL selector = NSSelectorFromString(@"setStatusBarOrientation:");
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIApplication instanceMethodSignatureForSelector:selector]];
        UIDeviceOrientation orentation = UIDeviceOrientationPortrait;
        [invocation setSelector:selector];
        [invocation setTarget:[UIApplication sharedApplication]];
        [invocation setArgument:&orentation atIndex:2];
        [invocation invoke];
    }
}