且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式添加GADBannerView

更新时间:2023-11-30 15:48:34

嗯,我认为你需要考虑多个事项:

Well I think you have multiple things to consider:


  1. [sender.view addSubview:bannerView] 不会移动其他视图,
    而不是将横幅视图直接放在视图
    层次结构的顶部。

  1. [sender.view addSubview:bannerView] does not move other views, instead you are placing the banner view directly on top of the view hierarchy.

广告是异步加载的,所以你应该实现 GADBannerView 的委托
方法,以显示和隐藏广告视图。

Ads are loaded asynchronously, so you should implement the delegate methods of GADBannerView for showing and hiding the ad view.

如果你真的想要移动其他视图你应该使用一些
类型的容器视图来包含除
横幅之外的所有其他内容。如果您收到广告,则可以轻松移动容器视图
(或缩小它),并在
主视图中的某个位置显示横幅广告视图。

If you really want to move other views around you should use some kind of container view to include all other content except your banner. If you receive an ad you can easily move the container view (or shrink it) and display your banner view on some location in your main view.

干杯