アプリに AdMob バナーを表示したい UIViewcontrollers では動作するようになりましたが、UIView では動作しませんでした... バナーは表示されますが、クリックしても何も起こりません! UIViewcontrollers のバナーをクリックすると動作します!
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 = self; 警告が表示されますが、それなしでは機能しません! 警告には、「互換性のないポインター タイプが 'UIViezController *' from 'blandad *const_strong' に割り当てられています。
UIView の .m および .h ファイルの名前に当たり障りのないものです。
何が間違っていると思いますか?
/初心者