2012-10-10 56 views
5

我想將我的應用程序更新到ios 6.所以如何設置框架尺寸既舒適的iphone 4和iphone 5?如何在ios6中設置iphone 4和iphone 5的框架

+0

我有同樣的問題 –

+0

您可以使用自動佈局,同時創建您的app.Link教程:http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2 –

+0

請看看[這個問題](http://stackoverflow.com/questions/12527517/what-is-the-best-way-for-supporting-both-screen-resolution-of-iphone4-and-iphone)。可能會有所幫助。 –

回答

4

我可以使用計算屏幕大小,則調整視圖的高度等使用以下的方法

+(CGFloat)heightOf:(CGFloat)heightValue{ 
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; 

//NSLog(@"applciation Frame height = %f",applicationFrame.size.height); 
CGFloat heightRatio = (heightValue/480)*100; 

CGFloat height = (applicationFrame.size.height * heightRatio)/100; 
return height; 

}

然後我就像使用像

UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0,[Height heightOf:385], 320, 220)]; 

等等。 感謝您的回覆

+0

嗨,你能告訴我什麼是「身高高度:385」中的身高。 – 2013-04-26 13:17:06

0

ü可以檢查設備類型link或者您可以檢查是否比正常的一個在iPhone更大的視圖框4/4S然後調整你的框架

注:我使用第二種方法,是工作

1

爲iPhone 5和其他設備下面的代碼檢查

#define IS_IPHONE ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"]) 
#define IS_IPOD ([[[UIDevice currentDevice ] model] isEqualToString:@"iPod touch"]) 
#define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f 
#define IS_IPHONE_5 (IS_IPHONE && IS_HEIGHT_GTE_568) 

And check for more detail refer the question.

3

有不止一個處理情況的方式。

1>其中之一是正確使用自動調整大小。

2>另一種方法是使用新的自動佈局功能,但話又說回來,這將只適用於iOS 6

3支持>您可以創建單獨的榫的每個視圖一個用於iPhone 4和iPhone 5並根據運行的設備,您可以切換使用的.xib文件。

現在最好的方法是使用正確的自動調整大小。

更多你可以通過這些

1>Supporting iOS 4.3 to iOS 6.0

2>What is the best way for supporting both screen resolution of iPhone4 and iPhone5 ? - Auto layout in only iOS6

0

AutoLayout沒有爲我工作得那麼好。我的應用程序有幾個元素需要均勻分配。

快速修復解決方案(不是很好的做法)是在屏幕高度檢查時單獨指定座標。 (順便說一句,這是一個很好的教程。恥辱蘋果仍然沒有拿出IOS的任何實質性內容)。

如果你有你的屏幕上的幾個元素,那麼我相信你將不得不重新代替它們分別

CGFloat height = [UIscreen mainScreen].bounds.size.height; 
if(height==568.00){ 
self.imageName.frame = CGRectMake(x,y,width,height); 
... 
} 

對於一個模式或浮動屏幕出現在窗口的中央,你可以嘗試這個:

self.imgBadgeArea.frame = CGRectMake(self.view.bounds.size.width/2- self.imgBadgeArea.bounds.size.width/2, self.view.bounds.size.height/2 - self.imgBadgeArea.bounds.size.height/2, self.imgBadgeArea.bounds.size.width, self.imgBadgeArea.bounds.size.height); 

適用於3.5和4英寸。

相關問題