How to use NSLayoutConstraint in iOS 6?

和自甴很熟 提交于 2019-12-02 10:16:14

问题


My app should support both iPhone resolutions (5 and older) using iOS 5 and iOS 6. When I use autolayouts in IB, on iOS 5 app crashes like this: link

So, I am trying to use NSLayoutConstraint in code, but unsuccessfully yet.

Subquestions:

  1. I am adding constraints in viewDidLoad method, but is it correct?
  2. Does updateViewConstraints invoke by framework? I have never seen that it was invoked.
  3. I tried to use examples from apple's docs, but it was without effect to view.

Anybody knows how to do it?

PS: I know it's possible to make it manually by setting frames, but I would like to use NSLayoutConstraints.

UDP: Yes, I know, that's why i use NSLayoutConstraint in code. I can make condition for determining iOS version. The question is about iOS6.


回答1:


The AutoLayout feature is only compatible with iOS6 and is not supported in iOS5. Thus the crash

If you intend your app to be compatible with iOS5, you can't use AutoLayout in your XIB files.

You can only use older methods, like the AutoResizingMask for example (which is often sufficient for most cases anyway).



来源:https://stackoverflow.com/questions/12687979/how-to-use-nslayoutconstraint-in-ios-6

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