开发者

iPhone + AdMob + remove the Ad view

I have integrated AdMob in my iPhone application.

I am adding an Ad view in of my UIViewController as follows:

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

So, I will be able to see an Ad view on top of my UIViewController.

Now I have two problems:

  1. I am not able to tap on certain buttons of my UIViewController on which I have added the Ad View. So, for temporary purpose I adding the Ad view as:

    [self.view insertSubView:temp.view atIndex:1];
    
  2. 开发者_Go百科

    I want to remove the Ad view after sometime so I am using:

    [temp.view removeFromSuperView];
    

But my Ad view is not being removed.

Please help me.

Regards, Pratik


You're creating a memory leak here:

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

Pick one, don't use both.

You could then set a 'tag' for "temp":

temp.tag = 123;

Then when you want to remove it use:

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

Hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜