亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

iOS如何實現(xiàn)強制轉(zhuǎn)屏、強制橫屏和強制豎屏的實例代碼

 更新時間:2017年07月20日 09:14:04   作者:位之先  
本篇文章主要介紹了iOS如何實現(xiàn)強制轉(zhuǎn)屏、強制橫屏和強制豎屏的實例代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文介紹了iOS如何實現(xiàn)強制轉(zhuǎn)屏、強制橫屏和強制豎屏的實例代碼,分享給大家

今天項目中遇到正在看視頻的時候賬號被擠,如果當時是橫屏的情況下,需要強制豎屏。真頭疼,網(wǎng)上找了好多方法,終于解決啦。O(∩_∩)O~

強制橫屏:

[self interfaceOrientation:UIInterfaceOrientationLandscapeRight];

強制豎屏:

[self interfaceOrientation:UIInterfaceOrientationPortrait];

強制轉(zhuǎn)屏

- (void)interfaceOrientation:(UIInterfaceOrientation)orientation
{
  if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
    SEL selector = NSSelectorFromString(@"setOrientation:");
    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
    [invocation setSelector:selector];
    [invocation setTarget:[UIDevice currentDevice]];
    int val = orientation;
    // 從2開始是因為0 1 兩個參數(shù)已經(jīng)被selector和target占用
    [invocation setArgument:&val atIndex:2];
    [invocation invoke];
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論