应用程序崩溃'无法实例化名为NSLayoutConstraint的类' [英] App crash with 'Could not instantiate class named NSLayoutConstraint'

查看:145
本文介绍了应用程序崩溃'无法实例化名为NSLayoutConstraint的类'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.xib文件中,我如何保持iOS 6的Autolayout,但iOS版本低于6。

In a .xib file how do I keep the Autolayout on for iOS 6 but off for iOS below 6.

如果我将其关闭,我的.xib不会得到适当的布局。如果我在我的Iphone上以4.3崩溃的方式打开它。

If I turn it off my .xib doesn't get the proper layout . If I turn it on my Iphone with 4.3 crashes.

任何帮助都会感激不尽

谢谢

推荐答案

我不相信这是可能的,因为autolayout会更改应用程序的编译方式。我考虑解决这个问题的方法是:

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:


  • 检测显示器的高度并以编程方式更改某些元素(ick) ,但我只是做了一个简单的改动就完成了这个。)

  • 检测显示器的高度并以编程方式加载适当的笔尖(缺点是保持两个笔尖)

  • 忽略4显示并使用黑色边框提交(假设没人应该这样做)

  • 尝试设计不会有额外空间的布局。(这总是可取的,但并不总是可行的.UIScrollViews / UITableViews绝对不错,但不是固定的全屏视图。)

  • 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.

这是我用来确定4vs 3.5iphone的代码:

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
}

即使这似乎是hackish,但与Apple谈论此事。 :|

Even this seems hackish, but talk to Apple about that. :|

这篇关于应用程序崩溃'无法实例化名为NSLayoutConstraint的类'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆