![](/img/trans.png)
[英]How to make the design of the application compatible with iPhone4/iPhone5/iPad? Is there any shortcut way?
[英]Making application compatible with iPhone4 and iPhone5 without setting diffrent frame size
今天,我要創建一個與iPhone4和iPhone5兼容的iPhone應用程序。 之前,我通過使用以下代碼來調整iphone5的控制器,從而以編程方式更改了iphone4應用程序視圖。
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for iphone5
}
else {
// code for iphone4
}
我認為很難每次都跟蹤控制器的所有框架和大小。 我創建了一個示例應用程序,還嘗試在視圖開始時使用“自動調整大小”選項(我已勾選了),並在檢查器中選擇了全尺寸的Retina 4。 並且還選擇了模擬器硬件設備是iphone Retina-4英寸
如果我更改模擬器硬件設備為iPhone Retina-3.5英寸,則屏幕看起來像
我的問題是不設置框架如何解決此問題。 請幫我。 提前致謝。
您可以使用此鏈接自動調整大小
http://blog.mugunthkumar.com/coding/supporting-the-iphone-5/
與其給出static
數字,不如給出dynamically
幀。 意味着不必給320提供self.view.frame.size.width
因此您無需檢查設備,只需要添加默認啟動屏幕即可。
使用XCode版本4.x中提供的自動布局功能可以輕松解決您的問題。 通過以下鏈接:-
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
通過使用“自動布局”應用少量約束,可以輕松解決問題。 快樂編碼:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.