Trouble hiding iAd banner and displaying UIWebView in its place

后端 未结 1 1982
北恋
北恋 2021-01-17 02:41

When there is no iAd banner to display, we would like to display a UIWebView of the same dimensions pointed to a specific URL.

However, hiding the iAd banner and sho

相关标签:
1条回答
  • 2021-01-17 03:05

    It's me again :)

    You're not adding it to the sub view tree.

    From your __prepare method

    self.houseAdView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)];
    self.houseAdView.frame = self.adView.frame;
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://www.panabee.com"]];
    [self.houseAdView loadRequest: request];
    

    That's great. But it doesn't work - you are missing one line of code - a critical, vital line that gets every developer some time or another.

    [self addSubview:self.houseAdView];
    

    I'm making a few assumptions, like that self is a UIView. Test before shipping.

    So, that part of your __prepare method should look like this:

    self.houseAdView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)];
    self.houseAdView.frame = self.adView.frame;
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://www.panabee.com"]];
    [self.houseAdView loadRequest: request];
    [self addSubview:self.houseAdView];
    
    0 讨论(0)
提交回复
热议问题