不能在横幅广告上变异(设置).isHidden

时间:2012-11-20 07:14:03

标签: ios iad

我的故事板中有一个iAd横幅,并将一个插座拖到了我的班级。我现在只是想做一个简单的实现(没有动画),但是当我尝试设置self.adBanner.isHidden时,不明白为什么“没有setter方法'setIsHidden'用于赋值给属性”被抛出为错误?我已经包含了iAd框架。

#import "MyClass.h"
#import <iAd/iAd.h>

@interface MyClass () <ADBannerViewDelegate>
@property (weak, nonatomic) IBOutlet ADBannerView *adBanner;
@end

@implementation MyClass
@synthesize adBanner = _adBanner;

- (void)viewDidLoad {
  [super viewDidLoad];
  self.adBanner.delegate = self;
  self.adBanner.isHidden = YES;
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
  self.adBanner.isHidden = NO;
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
  self.adBanner.isHidden = YES;
}

@end

2 个答案:

答案 0 :(得分:4)

你试图在那里“变异”(设置)一个吸气剂。请改用self.adBanner.hidden = YES

答案 1 :(得分:1)

啊,愚蠢的错误。 isHidden是只读属性。我误认为hidden的财产。以下是最终工作代码供参考:

#import "MyClass.h"
#import <iAd/iAd.h>

@interface MyClass () <ADBannerViewDelegate>
@property (weak, nonatomic) IBOutlet ADBannerView *adBanner;
@end

@implementation MyClass
@synthesize adBanner = _adBanner;

- (void)viewDidLoad {
  [super viewDidLoad];
  self.adBanner.delegate = self;
  self.adBanner.hidden = YES;
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
  self.adBanner.hidden = NO;
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
  self.adBanner.hidden = YES;
}

@end