2012-12-08 49 views
0

我剛從admob更新了文件,現在用[bannerView_addSubview:closeBtn];我再也看不到按鈕了。有人可以幫我解決問題嗎?Admob和addSubview:

回答

0

以下是在.h

#import "GADBannerView.h" 

AdMob爲代碼,

和申報

GADBannerView *AdMob; 

.m

#define AdMob_ID @"yourAdMobId" 

然後,只需調用這個方法,並提供你的X和Y

-(void)adMobCode 
{ 

    AdMob = [[GADBannerView alloc] 
      initWithFrame:CGRectMake(0.0,410, 
             GAD_SIZE_320x50 .width, 
             GAD_SIZE_320x50.height)]; 

    AdMob.adUnitID = AdMob_ID; 
    AdMob.rootViewController = self; 
    [self.view addSubview:AdMob]; 


    UIButton *Yourbtn = [[UIButton alloc]initWithFrame:CGRectMake(0, AdMob.frame.origin.y, 30, 30)]; 
    Yourbtn.tag=2; 
    [Yourbtn addTarget:self action:@selector(YourbtnPress:) forControlEvents:UIControlEventTouchDown]; 
    UIImage *PlayBtnImage = [UIImage imageNamed:@"play.png"]; 
    [Yourbtn setImage:PlayBtnImage forState:UIControlStateNormal]; 
    [self.view addSubview:Yourbtn]; 


    GADRequest *r = [[GADRequest alloc] init]; 
    r.testing = YES; 
    [AdMob loadRequest:r]; 
} 
+0

我知道如何添加一個橫幅,問題是,我沒有看到我的UIView在GADBannerView當我使用[bannerView_ addSubview:closeBtn]; – Alby

+0

檢查您的互聯網連接和r.testing = YES; – Rajneesh071

+0

該廣告正確顯示!我想要一個按鈕在adview上! – Alby

0

你可以嘗試:

[bannerView_ bringSubviewToFront:closeBtn]; 
+0

我試過了,沒有結果......非常奇怪。無論如何,我會在self.view中添加按鈕視圖。 – Alby