iAd横幅视图委托不调用方法 [英] iAd Banner View Delegate Not Calling Methods
问题描述
我有一个iAd横幅视图,所有合同都已启动并运行,并且已经实现了ADBannerView
委托.标语应在没有互联网连接的情况下消失,但仅在内容应显示的地方显示一个白框.我知道我所有的代码都正确,我已经看过一百万本教程.因此,我进行了一些测试,发现横幅视图甚至都没有为委托调用这两种方法!这是代码.
I have an iAd banner view, with all my contracts up and running, and I've implemented the ADBannerView
delegate. The banner should disappear with no internet connection, but it just shows a white box where the content should be. I know I have all the code right, I've seen a million tutorials on this. So I ran some tests and found that the banner view wasn't even calling the two methods for the delegate! Here is the code.
在.h文件中:
#import <iAd/iAd.h>
@interface DetailViewController : ADBannerViewDelegate>
{
ADBannerView *aBanner;
BOOL bannerIsVisible;
}
@property (nonatomic, retain) IBOutlet ADBannerView *aBanner;
@property (nonatomic, assign) BOOL bannerIsVisible;
@end
在.m文件中:
@implementation DetailViewController
@synthesize aBanner,bannerIsVisible;
//Show banner if can load ad.
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:NULL]; banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations]; self.bannerIsVisible = YES; }
}
//Hide banner if can't load ad.
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL]; banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations]; self.bannerIsVisible = NO; }
}
推荐答案
您必须将标题委托设置为文件所有者.我遇到了同样的问题,把头撞在墙上之后,事情就这么简单了.
You have to set the banner delegate to files owner. I had the same issue and after beating my head against the wall it was that simple.
这篇关于iAd横幅视图委托不调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!