久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 iOS 6 中啟用自動布局,同時保持向后兼容 iO

Enabling auto layout in iOS 6 while remaining backwards compatible with iOS 5(在 iOS 6 中啟用自動布局,同時保持向后兼容 iOS 5)
本文介紹了在 iOS 6 中啟用自動布局,同時保持向后兼容 iOS 5的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在利用 iOS 6 新的自動布局功能的同時,還能在早期版本的 iOS 上提供與舊設備的兼容性的最佳方式是什么?

解決方案

可以在每個 .storyboard 或 .xib 文件上啟用或禁用自動布局.只需選擇特定文件并使用 Xcode 中的文件檢查器修改使用自動布局"屬性:

使用啟用自動布局的接口文件并將部署目標設置為 6.0 之前的 iOS 版本會導致編譯錯誤,例如:

<塊引用>

MainStoryboard.storyboard:3 中的錯誤:iOS 6.0 之前版本的自動布局

在項目中使用自動布局并仍然保持與 iOS4-5 的兼容性的一種選擇是創建兩個 指出的那樣,如果您從代碼加載情節提要文件并且不使用主要Storyboard"設置在Xcode中設置初始storyboard,可以使用單個target.

對我來說,維護多個目標和接口文件所增加的復雜性成本似乎超過了使用自動布局的好處.除了少數特殊情況,如果需要 iOS4-5 兼容性,您可能最好使用普通的舊自動調整大小(或代碼中的 layoutSubViews).

What is the best way to take advantage of the new auto layout features of iOS 6 while still providing compability with older devices on earlier versions of iOS?

解決方案

Autolayout can be enabled or disabled on each .storyboard or .xib file. Just select the particular file and modify the "Use Autolayout" property using the File inspector in Xcode:

Using autolayout enabled interface files with the deployment target set to an iOS version prior to 6.0 results in compilation errors, e.g.:

Error in MainStoryboard.storyboard:3: Auto Layout on iOS Versions prior to 6.0

One of your options to use autolayout in a project and still preserve compatibility with iOS4-5 is to create two targets: one for deployment target iOS 6.0 and one for an earlier iOS version, e.g.:

You can create two versions for each of your storyboard and XIB files as well and use the autolayout enabled with the 6.0 target and the other with the legacy target, e.g.:

You then add MainStoryBoardAutoSize to the iOS6 target's Build phases and the other file to the iOS4 target. You can learn more about using multiple targets here.

EDIT: As marchinram's answer points out, if you load you storyboard files from code and do not use the "Main Storyboard" setting in Xcode to set the initial storyboard, you can use a single target.

For me, the cost of the added complexity of maintaining multiple targets and interface files seems to outweigh the benefits of using autolayout. Except for a few special cases, you are probably much better to use plain old auto sizing (or layoutSubViews from code) exclusively if iOS4-5 compatibility is required.

這篇關于在 iOS 6 中啟用自動布局,同時保持向后兼容 iOS 5的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應用程序源代碼的情況下使用 Instruments 測試 iOS 應用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 国产精品久久久久久久岛一牛影视 | 日韩精品久久久久 | 日批日韩在线观看 | 国产三级国产精品 | 岛国av免费观看 | 欧美国产日韩在线观看 | 日日摸夜夜添夜夜添精品视频 | 久久久久久国产 | 亚洲成av | 亚洲免费久久久 | 国产日韩欧美一区二区在线播放 | 91免费观看视频 | 日本不卡一区二区三区在线观看 | 亚洲精品第一国产综合野 | 免费中文字幕日韩欧美 | 九九综合 | 国产精品久久一区二区三区 | 成人在线免费电影 | 超碰在线人人 | 欧美一级艳情片免费观看 | 一区二区三区国产 | 亚洲一区精品视频 | 日本精品视频一区二区三区四区 | 范冰冰一级做a爰片久久毛片 | 欧美日韩综合精品 | 在线一区视频 | 午夜精品久久久久久久星辰影院 | 亚洲国产精品久久久久婷婷老年 | 国产精品久久久久久模特 | 亚洲福利一区 | jizz亚洲人 | 国产一区二区在线免费观看 | 玖玖视频网 | 国产成人精品一区二区三区四区 | 日韩欧美视频 | 中文字幕av第一页 | 日韩小视频 | 国产精品久久久久久中文字 | h片在线免费看 | 蜜月va乱码一区二区三区 | 免费精品 |