iAd错误:setValue:forUndefinedKey:]:此类不是键值adView的键值编码兼容

时间:2013-10-17 21:24:11

标签: ios objective-c iad adbannerview

我正在帮助理解为什么在尝试使用iAd横幅运行测试应用时出现此错误:

iAdTest[12856:a0b] *** Terminating app due to uncaught exception 'NSUnknownKeyException',
 reason: '[<KAMViewController 0xa239f50> setValue:forUndefinedKey:]: this class is not key 
value coding-compliant for the key adView.'
*** First throw call stack:

我的代码是:

·H

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface KAMViewController : UIViewController <ADBannerViewDelegate>
@property (strong, nonatomic) IBOutlet ADBannerView *bannerAd;
@property (nonatomic, assign) BOOL bannerIsVisible;
@end

的.m

- (void)viewDidLoad
{
// Do any additional setup after loading the view, typically from a nib.
_bannerAd = [[ADBannerView alloc] initWithFrame:CGRectZero];
_bannerAd.frame = CGRectOffset(_bannerAd.frame, 0, -50);
[_bannerAd setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:_bannerAd];
_bannerAd.delegate = self;
self.bannerIsVisible = NO;
[super viewDidLoad];
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!self.bannerIsVisible) {
    [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
    banner.frame = CGRectOffset(banner.frame, 0, 50);
    [UIView commitAnimations];
    self.bannerIsVisible = YES;
}
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (self.bannerIsVisible) {
    [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    banner.frame = CGRectOffset(banner.frame, 0, -50);
    [UIView commitAnimations];
    self.bannerIsVisible = NO;
}
}

单视图故事板(XCode 5.0)仅应用了ADBannerView,因为这是一个简单的测试程序,用于了解如何实现iAd&amp;确保它随方向变化等而旋转。

谢谢!

编辑:

我正在尝试使用iAd指南将它拼凑在一起。谷歌 - 但我没有得到'bannerView'来自这里???:

(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{

if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
    self.bannerView.currentContentSizeIdentifier =
        ADBannerContentSizeIdentifierLandscape;
else
    self.bannerView.currentContentSizeIdentifier =
}
ADBannerContentSizeIdentifierPortrait;

0 个答案:

没有答案