【问题标题】:warning while app goes to landscape应用程序进入横向时发出警告
【发布时间】:2013-08-02 16:02:38
【问题描述】:

版本:

所有子视图都放在控制器的 xib 中。一切正常,直到应用程序在 iPad 模拟器中以纵向模式运行,只要模拟器旋转它就会打印一些警告:

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:0x855f4c0 V:[MKNumberBadgeView:0x853fb70]-(743)-|   (Names: '|':UIView:0x855b3b0 )>",
"<NSLayoutConstraint:0x855f480 V:|-(5)-[MKNumberBadgeView:0x853fb70]   (Names: '|':UIView:0x855b3b0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x76b48e0 h=-&- v=-&- UILayoutContainerView:0x8334f10.width == UIWindow:0x8334010.width>",
"<NSAutoresizingMaskLayoutConstraint:0x76b2ed0 h=-&- v=-&- UITransitionView:0x8336250.height == UILayoutContainerView:0x8334f10.height - 49>",
"<NSAutoresizingMaskLayoutConstraint:0x767e1d0 h=--- v=--- H:[UIWindow:0x8334010(768)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7678c40 h=-&- v=-&- UIViewControllerWrapperView:0x76565f0.height == UITransitionView:0x8336250.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7677290 h=-&- v=-&- UILayoutContainerView:0x83371a0.height == UIViewControllerWrapperView:0x76565f0.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7675b60 h=-&- v=-&- UINavigationTransitionView:0x83398e0.height == UILayoutContainerView:0x83371a0.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7674320 h=-&- v=-&- UIViewControllerWrapperView:0xf529bf0.height == UINavigationTransitionView:0x83398e0.height - 20>",
"<NSAutoresizingMaskLayoutConstraint:0x76729e0 h=-&- v=-&- UIView:0x855b3b0.height == UIViewControllerWrapperView:0xf529bf0.height>"
)
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x855f4c0 V:[MKNumberBadgeView:0x853fb70]-(743)-|   (Names: '|':UIView:0x855b3b0    )>

我在谷歌上找到了解决方案并找到了setTranslatesAutoresizingMaskIntoConstraints但不幸的是,这些警告仍然存在。有什么建议/帮助吗?

【问题讨论】:

  • 贴出显示您如何创建视图和添加约束的代码会更有用。
  • @rdelmar 所有视图和约束都在 xib 中。

标签: ios objective-c constraints autolayout


【解决方案1】:

这两个约束:

V:|-(5)-[MKNumberBadgeView:0x853fb70]

V:[MKNumberBadgeView:0x853fb70]-(743)-|

告诉布局管理器您希望将MKNumberBadgeView 固定在距其超级视图顶部 5 点和距底部 743 点的位置。 iPad 的屏幕宽 768 点(或高,横向),将状态栏减去 20 点只剩下 748 点。布局中没有空间来满足这些约束,除非您的 MKNumberBadgeView 的高度为零。

您需要在 xib 中找到约束并更正它们。您实际上似乎不太可能需要将徽章视图的底部固定到其超级视图的底部,单独固定顶部并具有固有高度应该没问题。

【讨论】:

  • 好吧,我想通了。我只需选择 MKNumberBadgeView 和位于其下方的按钮,然后在它们之间放置垂直间距。 :) 谢谢。
  • <0x838db30 h:><0x83a5d00 h:><0x83af420 h:><0x83af3a0 h:><0x83af0a0 h:>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-20
  • 2010-10-13
  • 1970-01-01
  • 2017-03-20
  • 1970-01-01
相关资源
最近更新 更多