【发布时间】:2023-03-08 02:34:01
【问题描述】:
我有一个UITableView,下面有一个iAd Banner。我向他们申请了constraints:
有时,当我运行应用程序时,tableView 和 banner 加载后banner 之间有一个空格(banners 的高度)。这很奇怪,因为它只是偶尔发生。我无法确定它何时发生,何时不发生。
但是当有那个空间并且我旋转 iPhone 时,我会收到以下消息:
[4381:133861] 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:0x79039930 V:[UILabel:0x79039800'00:45'(57)]>",
"<NSLayoutConstraint:0x79036f30 V:[UIButton:0x79036d50'First'(60)]>",
"<NSLayoutConstraint:0x79035f80 V:[UIButton:0x79036620'second'(60)]>",
"<NSLayoutConstraint:0x79039ec0 V:|-(8)-[UILabel:0x79039800'00:45'] (Names: '|':UIView:0x79039d00 )>",
"<NSLayoutConstraint:0x79039f80 V:[UILabel:0x79039800'00:45']-(8)-[UIButton:0x79036d50'First']>",
"<NSLayoutConstraint:0x7903a070 V:[UIButton:0x79036d50'First']-(8)-[UIButton:0x79036620'second']>",
"<NSLayoutConstraint:0x7903a0a0 V:[UIButton:0x79036620'second']-(0)-| (Names: '|':UIView:0x79039d00 )>",
"<NSLayoutConstraint:0x79038240 V:|-(0)-[ADDimmerView:0x7861e140] (Names: '|':ADBannerView:0x79037290 )>",
"<NSLayoutConstraint:0x790382b0 V:[ADDimmerView:0x7861e140]-(0)-| (Names: '|':ADBannerView:0x79037290 )>",
"<NSLayoutConstraint:0x7903abb0 V:[_UILayoutGuide:0x7903a1e0]-(0)-[UIView:0x79039d00]>",
"<NSLayoutConstraint:0x7903ac40 V:[UIView:0x79039d00]-(8)-[UITableView:0x78c02a00]>",
"<NSLayoutConstraint:0x7903aca0 ADBannerView:0x79037290.bottom == _UILayoutGuide:0x7903a730.top>",
"<NSLayoutConstraint:0x7903acd0 V:[UITableView:0x78c02a00]-(0)-[ADBannerView:0x79037290]>",
"<_UILayoutSupportConstraint:0x790356e0 V:[_UILayoutGuide:0x7903a1e0(64)]>",
"<_UILayoutSupportConstraint:0x790357b0 V:|-(0)-[_UILayoutGuide:0x7903a1e0] (Names: '|':UIView:0x79039c40 )>",
"<_UILayoutSupportConstraint:0x79035920 V:[_UILayoutGuide:0x7903a730(0)]>",
"<_UILayoutSupportConstraint:0x79035680 _UILayoutGuide:0x7903a730.bottom == UIView:0x79039c40.bottom>",
"<NSLayoutConstraint:0x79045280 'UIView-Encapsulated-Layout-Height' V:[UIView:0x79039c40(270)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x79035f80 V:[UIButton:0x79036620'second'(60)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
我怎样才能摆脱那个空间?
这是我的代码:
func bannerViewDidLoadAd(banner: ADBannerView!) {
self.bottomAddView?.hidden = false
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
self.bottomAddView?.hidden = true
}
【问题讨论】:
-
您能否添加屏幕截图以更好地了解视图以及您如何设置约束。请选择所有视图,以便显示约束。
标签: ios swift autolayout nslayoutconstraint