我正在做 xamarin.ios,我正在做 UI,即 xcode 中的自动布局。
在 xcode 预览中...我可以看到 UI 很好,但在某些设备的设备中,UI 与预览中显示的不一样。
例如iPhone 5s,iPhone 6s plus。
谁能告诉我为什么会这样以及如何解决这个问题
谢谢
最佳答案
导致自动布局错误的原因有很多。有些是因为屏幕比例不同,有些是因为 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)]>"
)
不仅仅是调试它。
关于ios - 为什么自动布局预览和实际设备不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43167844/