【发布时间】:2015-10-27 13:54:16
【问题描述】:
我有一个带有横幅视图的视图控制器,我在那里集成了一个 admob 广告,我按照官方教程进行操作,但每次我关闭(不是多任务处理)并打开应用程序时它都会隐藏。为什么 ?我在 viewdidload 中添加了这个:
bannerView.adUnitID = "ca-app-pub-"
bannerView.rootViewController = self
let request = GADRequest()
request.testDevices = [ kGADSimulatorID ]
bannerView.loadRequest(request)
编辑
当我在控制台中运行应用程序时:
Google Mobile Ads SDK version: afma-sdk-i-v7.5.2
2015-10-27 15:16:01.146 Chat for WhatsApp[25348:2400768] 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.
(
"<NSLayoutConstraint:0x7fb9a4132e00 GADBannerView:0x7fb9a2f128e0.leading == UIView:0x7fb9a4131510.leadingMargin + 120>",
"<NSLayoutConstraint:0x7fb9a4137e10 H:|-(0)-[GADBannerView:0x7fb9a2f128e0] (Names: '|':UIView:0x7fb9a4131510 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fb9a4132e00 GADBannerView:0x7fb9a2f128e0.leading == UIView:0x7fb9a4131510.leadingMargin + 120>
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.
2015-10-27 15:16:01.147 Chat for WhatsApp[25348:2400768] 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.
(
"<NSLayoutConstraint:0x7fb9a4132db0 UIView:0x7fb9a4131510.trailingMargin == GADBannerView:0x7fb9a2f128e0.trailing + 120>",
"<NSLayoutConstraint:0x7fb9a4137e60 H:[GADBannerView:0x7fb9a2f128e0]-(0)-| (Names: '|':UIView:0x7fb9a4131510 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fb9a4132db0 UIView:0x7fb9a4131510.trailingMargin == GADBannerView:0x7fb9a2f128e0.trailing + 120>
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.
2015-10-27 15:16:01.172 Chat for WhatsApp[25348:2400768] 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.
(
"<_UILayoutSupportConstraint:0x7fb9a4129e50 V:[_UILayoutGuide:0x7fb9a41321c0(0)]>",
"<_UILayoutSupportConstraint:0x7fb9a4129e00 _UILayoutGuide:0x7fb9a41321c0.bottom == UIView:0x7fb9a4131510.bottom>",
"<NSLayoutConstraint:0x7fb9a4132e50 V:[GADBannerView:0x7fb9a2f128e0]-(0)-[_UILayoutGuide:0x7fb9a41321c0]>",
"<NSLayoutConstraint:0x7fb9a41380d0 V:[GADBannerView:0x7fb9a2f128e0]-(1)-| (Names: '|':UIView:0x7fb9a4131510 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fb9a4132e50 V:[GADBannerView:0x7fb9a2f128e0]-(0)-[_UILayoutGuide:0x7fb9a41321c0]>
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.
2015-10-27 15:16:01.180 Chat for WhatsApp[25348:2400768] 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.
(
"<NSLayoutConstraint:0x7fb9a2f07260 H:[GADBannerView:0x7fb9a2f128e0(320)]>",
"<NSLayoutConstraint:0x7fb9a4137e10 H:|-(0)-[GADBannerView:0x7fb9a2f128e0] (Names: '|':UIView:0x7fb9a4131510 )>",
"<NSLayoutConstraint:0x7fb9a4137e60 H:[GADBannerView:0x7fb9a2f128e0]-(0)-| (Names: '|':UIView:0x7fb9a4131510 )>",
"<NSLayoutConstraint:0x7fb9a2c1edf0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fb9a4131510(768)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fb9a2f07260 H:[GADBannerView:0x7fb9a2f128e0(320)]>
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.
这可能是一个约束问题?我有一个 WKWebView 和一个视图(横幅视图)
这是我的限制:
let viewsDictionary = ["top":webView, "bottom":bannerView]
let view_constraint_H:NSArray = NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[top]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: viewsDictionary)
let view_constraint_H2:NSArray = NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[bottom]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: viewsDictionary)
let view_constraint_V:NSArray = NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[top]-[bottom]-1-|", options: NSLayoutFormatOptions.AlignAllLeading, metrics: nil, views: viewsDictionary)
view.addConstraints(view_constraint_H as! [NSLayoutConstraint])
view.addConstraints(view_constraint_H2 as! [NSLayoutConstraint])
view.addConstraints(view_constraint_V as! [NSLayoutConstraint])
提前我的横幅视图不是 320x50,因为我在 iPad 上使用它 请帮助我,非常感谢您提前
【问题讨论】:
-
关闭和打开是什么意思?它会出现吗?
-
当我关闭应用程序时,比如点击主页按钮然后我返回应用程序,广告就会隐藏
-
尝试在重新打开应用时记录横幅视图,是否设置了约束?由于布局错误,它可能正在获取新广告或隐藏
-
@ogres 请查看编辑,谢谢
-
试试这个link 有同样的问题,它有帮助..