【问题标题】:Add iAd to Google Maps 1.7将 iAd 添加到 Google 地图 1.7
【发布时间】:2014-03-01 20:16:54
【问题描述】:

我想在谷歌地图上临时显示一个广告横幅。

因此我有以下代码:

WPMapViewController.h:

#import <iAd/iAd.h>
....
@interface WPMapViewController : UIViewController<ADBannerViewDelegate, GMSMapViewDelegate>

WPMapViewController.m:

@implementation WPMapViewController {

    GMSMapView *mapView_;
    ADBannerView *_bannerView;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        // On iOS 6 ADBannerView introduces a new initializer, use it when available.
        if ([ADBannerView instancesRespondToSelector:@selector(initWithAdType:)]) {
            _bannerView = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
        } else {
            _bannerView = [[ADBannerView alloc] init];
        }
        _bannerView.delegate = self;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    screenSize = [[UIScreen mainScreen] bounds].size;

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:51.7
                                                        longitude:10.4
                                                             zoom:5.3];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

    self.view = mapView_;

    mapView_.delegate = self;

    _bannerView.frame = CGRectMake(0, screenSize.height - 50, 320, 50);
    [self.view addSubview:_bannerView];
}

我猜是因为self.view = mapView_; _bannerView.delegate 被覆盖了。运行此代码时,我可以看到广告横幅,但无法单击它。
当我评论 self.view = mapView_; 时,横幅按预期工作,但我看不到地图。

self.canDisplayBannerAds = YES; 不适合我,因为它会缩小地图。

向这个 UIViewController 添加 iAd 横幅的正确方法是什么?

【问题讨论】:

  • 这可能是因为子视图继承了父视图的交互属性?您是否尝试过设置 self.view.userInteractionEnabled = YES;看看这是否允许横幅视图获得触摸?
  • 我是第一个尝试这个的人吗?还是您需要更多信息?
  • 我也遇到了关于嵌入表格视图的类似问题。表格视图检测到触摸但不滚动。这似乎发生在 1.7 更新之后。

标签: ios7 iad google-maps-sdk-ios


【解决方案1】:

我通过更改来修改您的来源

mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

mapView_ = [GMSMapView mapWithFrame:self.view.frame camera:camera];

然后显示地图和 iAd 横幅,横幅位于屏幕底部。

【讨论】:

  • 谢谢,还是不能点击
  • @AlexanderScholz ,也许你应该尝试在 DeveloperCenter/iTunesConnect 中添加一个 App,然后将 Xcode 项目链接到这个 App。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-13
  • 2015-07-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多