真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

關(guān)于IOS屏幕的旋轉(zhuǎn)問(wèn)題-創(chuàng)新互聯(lián)

處理IPhone屏幕的旋轉(zhuǎn)是我們經(jīng)常遇到的,當(dāng)你做一個(gè)應(yīng)用既然滿足豎屏又要滿足橫屏,這就要求我們會(huì)處理屏幕旋轉(zhuǎn)的問(wèn)題!

成都創(chuàng)新互聯(lián)是一家專注于做網(wǎng)站、網(wǎng)站制作與策劃設(shè)計(jì),三河網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:三河等地區(qū)。三河做網(wǎng)站價(jià)格咨詢:13518219792

方法一:自動(dòng)布局

1.將項(xiàng)目中界面的四種手持方式都點(diǎn)上;

2.取消Use Autolayout;

3.選擇界面中某個(gè)控件然后到屬性工具欄中去找到AutoSizing功能,勾選對(duì)應(yīng)的絕對(duì)定位的線條

4.重寫可以旋轉(zhuǎn)的方法

-(BOOL)shouldAutorotate {     return YES; } -(NSUInteger)supportedInterfaceOrientations {     return UIInterfaceOrientationMaskAll; }


方法二:手動(dòng)布局一(通過(guò)代碼改view種控件的坐標(biāo))

1.重寫可以旋轉(zhuǎn)的方法

-(BOOL)shouldAutorotate {     return YES; } -(NSUInteger)supportedInterfaceOrientations {     return UIInterfaceOrientationMaskAll; }
2.勾選上項(xiàng)目中支持的四種手持類型

3.取消Use Autolayout

4.代碼實(shí)現(xiàn):

//每當(dāng)屏幕旋轉(zhuǎn)的時(shí)候都會(huì)觸發(fā)一個(gè) -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {     //如果是是橫屏狀態(tài)     if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft )     {         self.l1.frame = CGRectMake(20, 25, 110, 110);         self.l2.frame = CGRectMake(162, 25, 110, 110);         self.l3.frame = CGRectMake(304, 25, 110, 110);         self.r1.frame = CGRectMake(20, 178, 110, 110);         self.r2.frame = CGRectMake(162, 178, 110, 110);         self.r3.frame = CGRectMake(304, 178, 110, 110);} }

方法三:手動(dòng)布局二(在xib中新建一個(gè)支持橫屏的view通過(guò)雙view切換實(shí)現(xiàn))

1.在xib文件中拖一個(gè)view控件,選擇Orientation屬性為橫屏

2.布局好界面

3.將橫縱view分別在controller.h文件中創(chuàng)建對(duì)應(yīng)的屬性,命名為

@property (retain, nonatomic) IBOutlet UIView *landspaceView;

@property (retain, nonatomic) IBOutlet UIView *portatiorView;

4.代碼實(shí)現(xiàn)

宏定義實(shí)現(xiàn)角度轉(zhuǎn)弧度

#define degreesToRadia(x) (M_PI * (x) / 180)//參數(shù)要加括號(hào) ,尤其是參數(shù)附近特別要加括號(hào)

-(BOOL)shouldAutorotate {     return YES; } -(NSUInteger)supportedInterfaceOrientations {     return UIInterfaceOrientationMaskAll; } //每當(dāng)屏幕旋轉(zhuǎn)的時(shí)候都會(huì)觸發(fā)一個(gè) -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {     //如果是是橫屏狀態(tài)     if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft )     { //        self.l1.frame = CGRectMake(20, 25, 110, 110); //        self.l2.frame = CGRectMake(162, 25, 110, 110); //        self.l3.frame = CGRectMake(304, 25, 110, 110); //        self.r1.frame = CGRectMake(20, 178, 110, 110); //        self.r2.frame = CGRectMake(162, 178, 110, 110); //        self.r3.frame = CGRectMake(304, 178, 110, 110);         self.view = self.landspaceView;         //self.view.transform = CGAffineTransformIdentity;         self.view.transform = CGAffineTransformMakeRotation(degreesToRadia(270));         self.view.bounds = CGRectMake(0, 0, 480, 300);     }     else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)     { //        self.l1.frame = CGRectMake(37, 20, 110, 110); //        self.l2.frame = CGRectMake(37, 162, 110, 110); //        self.l3.frame = CGRectMake(37, 304, 110, 110); //        self.r1.frame = CGRectMake(190, 20, 110, 110); //        self.r2.frame = CGRectMake(190, 162, 110, 110); //        self.r3.frame = CGRectMake(190, 304, 110, 110);         self.view = self.landspaceView;         //self.view.transform = CGAffineTransformIdentity;         self.view.transform = CGAffineTransformMakeRotation(degreesToRadia(90));         self.view.bounds = CGRectMake(0, 0, 480, 300);     }     else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)     {         self.view = self.portatiorView;         self.view.transform = CGAffineTransformIdentity;         self.view.bounds = CGRectMake(0, 0, 320, 460);     }     else if(toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)     {         self.view = self.portatiorView;         //self.view = self.landspaceView;         //self.view.transform = CGAffineTransformIdentity;         self.view.transform = CGAffineTransformMakeRotation(degreesToRadia(180));         self.view.bounds = CGRectMake(0, 0, 320, 460);     } }

模擬屏幕旋轉(zhuǎn)
commond + 方向鍵

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。


分享名稱:關(guān)于IOS屏幕的旋轉(zhuǎn)問(wèn)題-創(chuàng)新互聯(lián)
本文路徑:http://weahome.cn/article/dhpici.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部