App crash with 'Could not instantiate class named NSLayoutConstraint'

落爺英雄遲暮 提交于 2019-12-24 18:33:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!