偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

iOS橫豎屏解決方案

移動(dòng)開(kāi)發(fā) iOS
ios橫豎屏的效果是不相同的,所以我們?cè)陂_(kāi)發(fā)中如果允許屏幕橫豎屏間的切換,那么我們就要調(diào)整視圖的布局。利用Interface Builder開(kāi)發(fā),我們可以快速的拖拽出合適的界面布局。

ios橫豎屏的效果是不相同的,所以我們?cè)陂_(kāi)發(fā)中如果允許屏幕橫豎屏間的切換,那么我們就要調(diào)整視圖的布局。利用Interface Builder開(kāi)發(fā),我們可以快速的拖拽出合適的界面布局,但是屏幕自動(dòng)切換布局不能很好的適配,下圖是,沒(méi)有做任何調(diào)整的狀態(tài)下,實(shí)現(xiàn)的橫豎屏切換,可以看到界面不是很美觀(guān)。

image39.pngimage40.png

目前我所知的實(shí)現(xiàn)ios橫豎屏切換的解決方案共有三種:

1.利用Interface Builder適配器自動(dòng)適配調(diào)整界面。

2.在橫豎屏切換時(shí),每個(gè)控件重新布局。

3.利用Interface Builder創(chuàng)建兩個(gè)視圖,橫屏?xí)r切換到橫屏視圖,豎屏?xí)r切換到豎屏視圖。

在ios中,橫豎屏切換時(shí),會(huì)調(diào)用下面函數(shù):

  1. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
  2.         if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft) { 
  3.             //zuo 
  4.         } 
  5.         if (interfaceOrientation==UIInterfaceOrientationLandscapeRight) { 
  6.             //you 
  7.         } 
  8.         if (interfaceOrientation==UIInterfaceOrientationPortrait) { 
  9.             //shang 
  10.         } 
  11.         if (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) { 
  12.             //xia 
  13.         } 
  14.         return YES; 
  15.     } 
  16.   

返回yes表示切換屏幕,返回no是不能向相應(yīng)的方向切換視圖。

下面分別介紹一下三種方法,***種方法最簡(jiǎn)單,但是效果是最差的,我們只需用Interface bulider修改相應(yīng)的屬性即可。實(shí)現(xiàn)的效果如下:
image41.pngimage42.png

實(shí)現(xiàn)的方法:

image43.png

選中控件,按command+3,上圖紅框部分的紅線(xiàn)表示距離不能自動(dòng)適配,要是虛線(xiàn)表示距離可以自動(dòng)適配。我們選擇可以自動(dòng)適配,***的結(jié)果就如上圖。

第二種方法:

第二種方法是相應(yīng)的控件和代碼相關(guān)聯(lián):

代碼:

  1. @interface ipad_demooViewController : UIViewController { 
  2.  
  3.        IBOutlet UIButton *myButton1; 
  4.         IBOutlet UIButton *myButton2; 
  5.         IBOutlet UIButton *myButton3; 
  6.         IBOutlet UIButton *myButton4; 
  7.         IBOutlet UIButton *myButton5; 
  8.         IBOutlet UIButton *myButton6; 
  9.     } 
  10.     @property (nonatomic,retain) UIButton *myButton1; 
  11.     @property (nonatomic,retain) UIButton *myButton2; 
  12.     @property (nonatomic,retain) UIButton *myButton3; 
  13.     @property (nonatomic,retain) UIButton *myButton4; 
  14.     @property (nonatomic,retain) UIButton *myButton5; 
  15.     @property (nonatomic,retain) UIButton *myButton6; 
  16.  
  17.     @end 
  18.   

和IB相關(guān)聯(lián):

更改每一個(gè)控件的布局:

  1. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
  2.        if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft) { 
  3.            //zuo 
  4.            self.myButton1.frame=CGRectMake(86, 208, 72, 37); 
  5.            self.myButton2.frame=CGRectMake(480, 208, 72, 37); 
  6.            self.myButton3.frame=CGRectMake(86, 308, 72, 37); 
  7.            self.myButton4.frame=CGRectMake(480, 308, 72, 37); 
  8.            self.myButton5.frame=CGRectMake(86, 408, 72, 37); 
  9.            self.myButton6.frame=CGRectMake(480, 408, 72, 37); 
  10.        } 
  11.        if (interfaceOrientation==UIInterfaceOrientationLandscapeRight) { 
  12.            //you 
  13.            self.myButton1.frame=CGRectMake(86, 208, 72, 37); 
  14.            self.myButton2.frame=CGRectMake(480, 208, 72, 37); 
  15.            self.myButton3.frame=CGRectMake(86, 308, 72, 37); 
  16.            self.myButton4.frame=CGRectMake(480, 308, 72, 37); 
  17.            self.myButton5.frame=CGRectMake(86, 408, 72, 37); 
  18.            self.myButton6.frame=CGRectMake(480, 408, 72, 37); 
  19.        } 
  20.        if (interfaceOrientation==UIInterfaceOrientationPortrait) { 
  21.            //shang 
  22.            self.myButton1.frame=CGRectMake(86, 208, 72, 37); 
  23.            self.myButton2.frame=CGRectMake(480, 208, 72, 37); 
  24.            self.myButton3.frame=CGRectMake(86, 308, 72, 37); 
  25.            self.myButton4.frame=CGRectMake(480, 308, 72, 37); 
  26.            self.myButton5.frame=CGRectMake(86, 408, 72, 37); 
  27.            self.myButton6.frame=CGRectMake(480, 408, 72, 37); 
  28.        } 
  29.        if (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) { 
  30.            //xia 
  31.            self.myButton1.frame=CGRectMake(86, 208, 72, 37); 
  32.            self.myButton2.frame=CGRectMake(480, 208, 72, 37); 
  33.            self.myButton3.frame=CGRectMake(86, 308, 72, 37); 
  34.            self.myButton4.frame=CGRectMake(480, 308, 72, 37); 
  35.            self.myButton5.frame=CGRectMake(86, 408, 72, 37); 
  36.            self.myButton6.frame=CGRectMake(480, 408, 72, 37); 
  37.        } 
  38.        return YES; 
  39.    } 

第三種方法是創(chuàng)建兩個(gè)視圖,下面看一下實(shí)現(xiàn)過(guò)程:

首先創(chuàng)建兩個(gè)視圖:

  1. IBOutlet UIView *hView; 
  2. IBOutlet UIView *vView; 
  3.   

創(chuàng)建相應(yīng)的@property方法.

然后在IB中在復(fù)制一個(gè)view。

image44.png

把一個(gè)視圖做橫屏?xí)r的布局,一個(gè)view做豎屏?xí)r的布局。把相應(yīng)的view和相應(yīng)的方法相連接,在設(shè)置一個(gè)默認(rèn)視圖為view。

下面就是代碼實(shí)現(xiàn):

  1. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
  2.         if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft) { 
  3.             //zuo 
  4.             self.view=self.hView; 
  5.            } 
  6.         if (interfaceOrientation==UIInterfaceOrientationLandscapeRight) { 
  7.             //you 
  8.             self.view=self.hView; 
  9.           } 
  10.         if (interfaceOrientation==UIInterfaceOrientationPortrait) { 
  11.             //shang 
  12.             self.view=self.vView; 
  13.            } 
  14.         if (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) { 
  15.             //xia 
  16.             self.view=self.vView; 
  17.           } 
  18.         return YES; 
  19.     } 
  20.   

實(shí)現(xiàn)的效果如下:

image45.pngimage46.png

上述就是我目前知道的三種橫豎屏解決方案,我們可以看到第三種比較簡(jiǎn)單,但是編寫(xiě)比較麻煩,實(shí)現(xiàn)復(fù)雜邏輯比較麻煩,第二種方法實(shí)現(xiàn)起來(lái)不直觀(guān),調(diào)試比較麻煩,但是效果***。

源代碼:http://easymorse-iphone.googlecode.com/svn/trunk/ipad.demoo/

ios6.0橫豎屏切換問(wèn)題解決

this class is not key value coding-compliant for the key

ios5里面的旋轉(zhuǎn)方法ios6里面確實(shí)掉不到了,但是還是可以用的。

首先,在app的主界面(也就是自己的主ViewController.m)里面加上

  1. -(NSUInteger)supportedInterfaceOrientations{ 
  2.     return UIInterfaceOrientationMaskAllButUpsideDown;//這里返回哪個(gè)值,就看你想支持那幾個(gè)方向了。這里必須和后面plist文件里面的一致(我感覺(jué)是這樣的)。 
  3.  
  4. - (BOOL)shouldAutorotate { 
  5.     return YES;//支持轉(zhuǎn)屏 
  6.   

這兩個(gè)函數(shù)。

然后在plist文件里面找到Supported interface orientations (iPad)選項(xiàng),添加你想支持的方向,都有提示的。

然后問(wèn)題就解決了。

也許我描述的還有問(wèn)題,希望你能指正。謝謝了。

  1. -(NSUInteger)supportedInterfaceOrientations{ 
  2.     return UIInterfaceOrientationMaskAllButUpsideDown;//這里返回哪個(gè)值,就看你想支持那幾個(gè)方向了。這里必須和后面plist文件里面的一致(我感覺(jué)是這樣的)。 
  3.   

這里的設(shè)置會(huì)覆蓋掉plist中的值

還有需要注意:mainViewController要設(shè)置為window的rootViewController,addSubView上去可能存在問(wèn)題。并且上面的所有subViewController都會(huì)受到rootViewController支持朝向的影響

責(zé)任編輯:張葉青 來(lái)源: eoe Android開(kāi)發(fā)者社區(qū)
相關(guān)推薦

2011-07-29 10:21:03

iPad 橫豎屏 切換

2017-12-26 14:05:21

潤(rùn)乾大屏可視化

2017-07-25 09:55:10

iOS橫豎屏旋轉(zhuǎn)

2018-12-03 12:17:27

Semptian解決方案

2012-05-27 16:21:31

IDC華為

2009-12-22 15:50:11

2020-02-05 11:20:39

微軟瀏覽器Windows

2018-12-03 11:59:42

Inventec解決方案

2018-12-03 12:26:30

YADRO解決方案

2018-12-03 12:13:21

Mellanox解決方案

2013-05-23 10:51:28

Android開(kāi)發(fā)移動(dòng)開(kāi)發(fā)橫豎屏切換

2016-03-13 17:58:57

2023-07-10 16:06:50

鴻蒙檢測(cè)鎖屏應(yīng)用

2011-08-03 09:44:18

IOS開(kāi)發(fā) UITextFiel UITableVie

2011-04-08 09:13:13

游戲跨平臺(tái)iOS

2009-07-15 17:09:32

Swing線(xiàn)程

2010-12-21 17:28:58

2012-05-27 17:01:36

華為云教育數(shù)據(jù)

2018-12-03 12:23:45

IBMMCM解決方案

2017-08-02 17:23:22

AzureIoTAWS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)