我想在我的应用中添加AdMob横幅! 我得到它在UIViewcontrollers工作,但不是在我的UIView ...横幅显示,但当你点击它,没有反应!如果你点击UIViewcontrollers中的横幅,它就可以工作!AdMob广告未出现在UIView中iPhone
守则UIViewcontrollers(工作!)
- (void)viewDidLoad
{
[super viewDidLoad];
bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height-49, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[bannerView_ loadRequest:r];
// Do any additional setup after loading the view, typically from a nib.
}
代码中的UIView:(不工作)
- (void)drawRect:(CGRect)rect
{
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.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 = MY_BANNER_UNIT_ID;
// 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 addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
// Drawing code
}
行bannerView_.rootViewController =自我;给我一个警告,但没有它,它就无法工作!警告说“不兼容的指针类型从‘blandad * const_strong’
blandad的名称为OM了UIView的的.m和.h文件分配给‘UIViezController *’!
你觉得有什么不对?
/A小白
http://stackoverflow.com/questions/18043931/set-admob-banner-to-appear-at-bottom-of-screen/18044011#18044011 – Guru