gpt4 book ai didi

cocoa - 带 admod 的 Xcode 4.4

转载 作者:行者123 更新时间:2023-12-03 17:04:56 25 4
gpt4 key购买 nike

我想在我的 ios 应用程序中添加 admob。

我已经遵循该教程:

https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=en#ios

但即使使用示例项目或使用该代码在我的 ios 项目中添加源代码,我也会遇到一个错误:

* 由于未捕获的异常“NSInvalidArgumentException”而终止应用,原因:“-[GADBannerView private]:发送到实例 0x1727d0 的无法识别的选择器”

使用该源代码:

ViewController.h

#import <UIKit/UIKit.h>
#import "GADBannerView.h"

@interface ViewController : UIViewController{
GADBannerView *bannerView_;
}

@end

还有

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"MYID";

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
}

- (void)viewDidUnload
{
[super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}

@end

最佳答案

我遇到了类似的问题。我通过使用 -all_load 链接器标志修复了它。

这就是您所需要的。

https://developers.google.com/mobile-ads-sdk/docs/#incorporating

关于cocoa - 带 admod 的 Xcode 4.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11725842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com