iOS如何實(shí)現(xiàn)強(qiáng)制轉(zhuǎn)屏、強(qiáng)制橫屏和強(qiáng)制豎屏的實(shí)例代碼
本文介紹了iOS如何實(shí)現(xiàn)強(qiáng)制轉(zhuǎn)屏、強(qiáng)制橫屏和強(qiáng)制豎屏的實(shí)例代碼,分享給大家
今天項(xiàng)目中遇到正在看視頻的時(shí)候賬號(hào)被擠,如果當(dāng)時(shí)是橫屏的情況下,需要強(qiáng)制豎屏。真頭疼,網(wǎng)上找了好多方法,終于解決啦。O(∩_∩)O~
強(qiáng)制橫屏:
[self interfaceOrientation:UIInterfaceOrientationLandscapeRight];
強(qiáng)制豎屏:
[self interfaceOrientation:UIInterfaceOrientationPortrait];
強(qiáng)制轉(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開(kāi)始是因?yàn)? 1 兩個(gè)參數(shù)已經(jīng)被selector和target占用
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
IOS CoreAnimation中l(wèi)ayer動(dòng)畫(huà)閃爍的解決方法
這篇文章主要為大家詳細(xì)介紹了IOS CoreAnimation中l(wèi)ayer動(dòng)畫(huà)閃爍的原因,分享了layer動(dòng)畫(huà)閃爍的解決方法,感興趣的小伙伴們可以參考一下2016-06-06
你應(yīng)該知道的tableViewCell行高計(jì)算處理
這篇文章主要給大家介紹了關(guān)于tableViewCell行高計(jì)算的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-12-12
ios開(kāi)發(fā)加載webview顯示進(jìn)度條實(shí)例
本篇文章主要介紹了ios開(kāi)發(fā)加載webview顯示進(jìn)度條實(shí)例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-05-05

