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

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

關(guān)于IOS屏幕的旋轉(zhuǎn)問題

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

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、托克遜網(wǎng)絡(luò)推廣、重慶小程序開發(fā)、托克遜網(wǎng)絡(luò)營銷、托克遜企業(yè)策劃、托克遜品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供托克遜建站搭建服務(wù),24小時服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com

方法一:自動布局

1.將項目中界面的四種手持方式都點上;

2.取消Use Autolayout;

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

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

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


方法二:手動布局一(通過代碼改view種控件的坐標)

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

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

3.取消Use Autolayout

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

//每當屏幕旋轉(zhuǎn)的時候都會觸發(fā)一個 -(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);} }

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

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

2.布局好界面

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

@property (retain, nonatomic)IBOutletUIView *landspaceView;

@property (retain, nonatomic)IBOutletUIView *portatiorView;

4.代碼實現(xiàn)

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

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

-(BOOL)shouldAutorotate {     return YES; } -(NSUInteger)supportedInterfaceOrientations {     return UIInterfaceOrientationMaskAll; } //每當屏幕旋轉(zhuǎn)的時候都會觸發(fā)一個 -(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ǎng)站名稱:關(guān)于IOS屏幕的旋轉(zhuǎn)問題
標題URL:http://weahome.cn/article/gpspjh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部