2010-02-26 64 views
1

我在iPhone應用程序中集成了AdMob。iPhone + AdMob +刪除廣告視圖

我在我的UIViewController添加廣告圖如下:

ProgrammaticAdViewController *temp = [[ProgrammaticAdViewController alloc] init]; 
temp = [[ProgrammaticAdViewController alloc] initWithNibName:nil bundle:nil]; 
[self.view addSubview:temp.view]; 

所以,我就能看到我的UIViewController頂部的廣告視圖。

現在我有兩個問題:

  1. 我不能夠利用上,我添加了廣告瀏覽我的UIViewController的某些按鈕。因此,對於臨時目的,我將廣告視圖:

    [self.view insertSubView:temp.view atIndex:1]; 
    
  2. 我想,所以我使用去除廣告視圖之後的某個時間:

    [temp.view removeFromSuperView]; 
    

但我的廣告的看法是不被刪除。

請幫幫我。

問候, PRATIK

回答

0

你在這裏創建了內存泄漏:

ProgrammaticAdViewController *temp = [[ProgrammaticAdViewController alloc] init]; 
temp = [[ProgrammaticAdViewController alloc] initWithNibName:nil bundle:nil]; 

選擇一個,不要同時使用。

然後,您可以設置 「臨時」 一個 '標籤':

temp.tag = 123; 

然後,當你想刪除它使用:

[[self.view viewWithTag:123] removeFromSuperview]; 

希望幫助

+0

temp.tag會不工作,因爲temp是ViewController類的實例,並且沒有標籤作爲其屬性。 – pratik

+0

然後在.h文件中聲明它。 –

+0

@Tom:對不起,我沒有得到你最後的評論... plz你可以詳細解釋一下 – pratik