0

在尝试仅使用 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 并确保它随着方向变化等而旋转。

谢谢!

编辑:

我正在尝试使用 iAd 指南和谷歌将其拼凑在一起 - 但我不知道“bannerView”来自哪里???:

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

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

0 回答 0