0

我的故事板中有一个 iAd 横幅,并将一个插座拖到我的班级。我现在只是尝试做一个简单的实现(没有动画),但是当我尝试设置 self.adBanner.isHidden 时,不明白为什么“没有 setter method 'setIsHidden' for assignment to property”作为错误抛出? 我已经包含了 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
4

2 回答 2

4

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

于 2012-11-20T07:21:56.927 回答
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
于 2012-11-20T07:22:23.413 回答