国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS如何實現強制轉屏、強制橫屏和強制豎屏的實例代碼

2020-07-26 02:44:54
字體:
來源:轉載
供稿:網友

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

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

強制橫屏:

[self interfaceOrientation:UIInterfaceOrientationLandscapeRight];

強制豎屏:

[self interfaceOrientation:UIInterfaceOrientationPortrait];

強制轉屏

- (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 兩個參數已經被selector和target占用    [invocation setArgument:&val atIndex:2];    [invocation invoke];  }}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南召县| 岳池县| 老河口市| 兰西县| 镇安县| 通河县| 沧源| 福泉市| 泗洪县| 江阴市| 连州市| 安国市| 怀仁县| 桃园县| 宝鸡市| 凤山县| 湛江市| 绥滨县| 富川| 克拉玛依市| 盱眙县| 利川市| 乌什县| 莱西市| 阿合奇县| 蕉岭县| 阆中市| 临朐县| 合川市| 西充县| 灵山县| 霞浦县| 弋阳县| 海宁市| 襄樊市| 红桥区| 连江县| 威远县| 西盟| 抚松县| 图木舒克市|