问题
In a .xib file how do I keep the Autolayout on for iOS 6 but off for iOS below 6.
If I turn it off my .xib doesn't get the proper layout . If I turn it on my Iphone with 4.3 crashes.
Any help would be appreciat it
Thank you
回答1:
I don't believe this is possible as autolayout changes how your application is compiled. The options I've considered for a workaround to this are:
- Detect the height of the display and programmatically change some of the elements (ick, but I've done this when it was just a simple change)
- Detect the height of the display and programmatically load the appropriate nib (the downside is maintaining two nibs)
- Ignore 4" displays and submit with black borders (let's assume no one should want this)
- Attempt to design layouts that won't suffer from having some additional space. (This is always desirable, but not always possible. UIScrollViews/UITableViews are definitely good with this, but not fixed full-screen views.)
I am still looking for better solutions myself.
Here is the code I use to determine 4" vs 3.5" iphone:
if (screenBounds.size.height == 568) {
// code for 4-inch screen
} else {
// code for 3.5-inch screen
}
Even this seems hackish, but talk to Apple about that. :|
来源:https://stackoverflow.com/questions/12892926/app-crash-with-could-not-instantiate-class-named-nslayoutconstraint