为什么autolayout预览和实际设备不匹配

时间:2017-04-02 11:36:05

标签: ios xamarin xamarin.ios xcode8 ios-autolayout

我正在做xamarin.ios,我正在做UI,即在xcode中自动布局。

在xcode预览中......我能够看到用户界面很好,但在某些设备的设备中,用户界面并不像预览中那样显示。

如iPhone 5s,iPhone 6s plus。

有人可以解释一下为什么会发生以及如何解决这个问题

感谢

1 个答案:

答案 0 :(得分:0)

导致自动布局错误的原因很多。其中一些因为屏幕比例不同,其中一些因为iOS版本不同。

你看看你的调试器输出并检查这样的消息:

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
    "<NSLayoutConstraint:0x7fc82d3e18a0 H:[UIView:0x7fc82aba1210(768)]>",
    "<NSLayoutConstraint:0x7fc82d6369e0 H:[UIView:0x7fc82aba1210]-(0)-|   (Names: '|':UIView:0x7fc82d6b9f80 )>",
    "<NSLayoutConstraint:0x7fc82d636a30 H:|-(0)-[UIView:0x7fc82aba1210]   (Names: '|':UIView:0x7fc82d6b9f80 )>",
    "<NSLayoutConstraint:0x7fc82d3e7fd0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fc82d6b9f80(50)]>"
)

不只是调试它。