iAd导致约束冲突

时间:2015-10-15 23:43:59

标签: ios swift storyboard iad

我试图弄清楚我的约束发生了什么...... Storyboard认为存在一些相互矛盾的constraints但不是我可以从我的内容中看出来#&# 39;手动设置。

显然这些是相互冲突的约束:

(
    "<_UILayoutSupportConstraint:0x7fc9a0431200 V:[_UILayoutGuide:0x7fc9a0587fc0(0)]>",
    "<_UILayoutSupportConstraint:0x7fc9a040e210 V:|-(0)-[_UILayoutGuide:0x7fc9a0587fc0]   (Names: '|':UIView:0x7fc9a0584b10 )>",
    "<_UILayoutSupportConstraint:0x7fc9a0404300 V:[_UILayoutGuide:0x7fc9a0588ad0(0)]>",
    "<_UILayoutSupportConstraint:0x7fc9a0400e00 _UILayoutGuide:0x7fc9a0588ad0.bottom == UIView:0x7fc9a0584b10.bottom>",
    "<NSLayoutConstraint:0x7fc9a0584860 V:[UIImageView:0x7fc9a0584f90(0)]>",
    "<NSLayoutConstraint:0x7fc9a058afb0 V:[_UILayoutGuide:0x7fc9a0587fc0]-(0)-[UIImageView:0x7fc9a0584f90]>",
    "<NSLayoutConstraint:0x7fc9a058b280 V:[UIImageView:0x7fc9a0584f90]-(0)-[_UILayoutGuide:0x7fc9a0588ad0]>",
    "<NSLayoutConstraint:0x7fc9a0775890 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fc9a0584b10(320)]>"
)

任何人都可以帮我弄清楚它的想法吗?我正在使用大小类,但从我可以看到所有正确的约束被安装/卸载..

好吧,似乎iAd导致我的constraints陷入困境......希望在横向广告中禁用横幅广告可以解决这个问题。

1 个答案:

答案 0 :(得分:0)

您可以尝试在代码中创建iAd banner,我总是喜欢这样。

以下是一些适用于我的工作代码。广告会根据屏幕尺寸自动更改尺寸,并位于屏幕底部。

import iAd

class viewController: UIViewController, ADBannerViewDelegate {

var AdBanner = ADBannerView()

override func viewDidLoad() {
    super.viewDidLoad()

        /* Ad Banner Settings */

        AdBanner = ADBannerView()
        AdBanner.frame = CGRectZero
        AdBanner.delegate = self
        self.AdBanner.frame = CGRectMake(0, self.view.frame.size.height-self.AdBanner.frame.size.height, self.AdBanner.frame.size.width, self.AdBanner.frame.size.height)
        AdBanner.backgroundColor = UIColor.clearColor()
        self.view .addSubview(AdBanner)

}

/* All iAd Functions */

func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
/* whatever you need */
    return true
}

func bannerViewActionDidFinish(banner: ADBannerView!) {
/* whatever you need */
}

func bannerViewDidLoadAd(banner: ADBannerView!) {
    AdBanner.hidden = false
}


func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
    NSLog("Error Loading Ad")
/* whatever you need */
    AdBanner.hidden = true
}
func bannerViewWillLoadAd(banner: ADBannerView!) {
/* whatever you need */
}