第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何只允許單個(gè)UIViewController沿橫向和縱向旋轉(zhuǎn)?

如何只允許單個(gè)UIViewController沿橫向和縱向旋轉(zhuǎn)?

慕的地8271018 2019-10-18 11:15:17
我的應(yīng)用僅適用于iphone設(shè)備(iphone 4和5),并且僅支持ios 6。我的整個(gè)應(yīng)用僅支持portrait模式。但是有一個(gè)名為“ ChatView”的視圖,我想同時(shí)支持landscape和portrait模式。我已將所需的設(shè)備旋轉(zhuǎn)設(shè)置如下:我還嘗試了以下代碼來支持“ ChatView”中的旋轉(zhuǎn)--(BOOL)shouldAutorotate{    return YES;}-(NSUInteger)supportedInterfaceOrientations{    return UIInterfaceOrientationMaskLandscape;}但是它無法旋轉(zhuǎn)該視圖。我為此進(jìn)行了很多搜索,但找不到我的問題的解決方案。而且在“ ChatView”中,還有一些對象,例如按鈕,文本字段,其框架是通過編程方式設(shè)置的。所以我想知道我是否還必須為橫向模式設(shè)置所有這些對象的框架?請幫我。謝謝.....
查看完整描述

3 回答

?
拉莫斯之舞

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊

簡單,但效果很好。iOS 7.1和8


AppDelegate.h


@property () BOOL restrictRotation;

AppDelegate.m


-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{

if(self.restrictRotation)

    return UIInterfaceOrientationMaskPortrait;

else

    return UIInterfaceOrientationMaskAll;

}

ViewController


-(void) restrictRotation:(BOOL) restriction

{

    AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;

    appDelegate.restrictRotation = restriction;

}

viewDidLoad


[self restrictRotation:YES]; or NO


查看完整回答
反對 回復(fù) 2019-10-18
?
人到中年有點(diǎn)甜

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊

您的視圖控制器將永遠(yuǎn)不會(huì)旋轉(zhuǎn)到應(yīng)用程序本身不支持的任何位置。您應(yīng)該啟用所有可能的旋轉(zhuǎn),然后在不應(yīng)旋轉(zhuǎn)的視圖控制器中放入以下行


- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskPortrait;

}

在ChatView中,應(yīng)為:


- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskAll;

}

如果您需要在輪換之后更改布局,則應(yīng)對子視圖進(jìn)行適當(dāng)?shù)母?/p>


- (void)viewWillLayoutSubviews

使用self.view.bounds檢查的電流的大小view,因?yàn)閟elf.view.frame旋轉(zhuǎn)后也不會(huì)改變。


查看完整回答
反對 回復(fù) 2019-10-18
  • 3 回答
  • 0 關(guān)注
  • 922 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)