开发者

iPhone + AdMob + remove the Ad view

开发者 https://www.devze.com 2022-12-21 14:08 出处:网络
I have integrated AdMob in my iPhone application. I am adding an Ad view in of my UIViewController as follows:

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

精彩评论

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

关注公众号