【发布时间】:2015-05-20 10:44:10
【问题描述】:
我在使用自动布局时遇到了一些问题。尤其是在 iOS8 中。
我已经看过网络,在使用UITableViewCell时发现了类似的问题。
但是这里我没有使用UITableViewCell,根本没有UITableView。
当它发生时,我只有一个ADBannerView 和一个UIWebView 来处理。
我在 Xcode 调试器中收到以下消息:
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:0x14e256f0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x14e6c870(568)]>",
"<NSLayoutConstraint:0x14d9b320 V:[ADBannerView:0x14d40c30(50)]>",
"<NSLayoutConstraint:0x14d97b00 V:|-(20)-[ADBannerView:0x14d40c30] (Names: '|':UIView:0x14e6c870 )>",
"<NSLayoutConstraint:0x14d34880 ADBannerView:0x14d40c30.bottom == UIView:0x14e6c870.bottom>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x14d34880 ADBannerView:0x14d40c30.bottom == UIView:0x14e6c870.bottom>
作为评论,我想说的第一件事。我不知道第一个约束(UIView-Encapsulated-Layout-Height)来自哪里。
第二件事;我添加了一个约束(尽管已经太多了),以强制执行ADBannerView 的高度,从而解决了显示问题。
但我仍然收到消息(如我所料)。
如果我不添加约束来强制执行ADBannerView 的高度。显示屏的背景变为白色,无论我在哪里点击都会触发 iAd。有点像ADBannerView 的高度填满了整个显示屏。
有解决这个问题的建议吗?
我当然没有忘记:
[adBanner setTranslatesAutoresizingMaskIntoConstraints:NO];
如果有人知道发生了什么,请告诉我。
【问题讨论】:
标签: ios uitableview uiview autolayout nslayoutconstraint