ios - 为什么自动布局预览和实际设备不匹配

标签 ios xamarin xamarin.ios xcode8 ios-autolayout

我正在做 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/

相关文章:

iOS Flicker API 只需上传一张公共(public)图片?

ListView 分隔符插入全宽

android - 在android中编写扩展View的类时出错

iphone - 在 UITableView 中删除项目时页脚不会更新

ios - Xamarin auth 查看关闭问题

ios - 是否可以将 UIScrollView 指示器从右侧移动到左侧?

ios - 使用 Facebook Graph API 我怎样才能访问 friend 的名字

javascript - 如何仅通过替换一些文本来更改 href 标签

c# - Xamarin.Mac 中有任何类似的 "ListView"UI 控件吗?

ios - 我如何自动化 Xamarin.iOS 单元测试项目