NSObject可能无法响应'onEnter'(在AppDelegate中使用iAd时)

时间:2012-07-04 13:20:32

标签: ios cocos2d-iphone iad

使用iAd。收到一些警告。 下面是我在AppDelegate.m中放置的代码

缺少什么?

警告以代码行结束

表示
-(void)onEnter
{
    [super onEnter]; //<-- NSObject may not respond to this
    adView = [[ADBannerView alloc]initWithFrame:CGRectZero];
    adView.delegate = self;
    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierLandscape, ADBannerContentSizeIdentifierLandscape, nil];
    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    [[[CCDirector sharedDirector] openGLView] addSubview:adView];
    adView.hidden = YES;
}


-(void)onExit
{
    adView.delegate = nil;
    [adView removeFromSuperview];
    [adView release];
    adView = nil;
    [super onExit]; //<-- NSObject may not respond to this
}



-(void)bannerViewActionDidFinish :(ADBannerView *)banner
    {    
        NSLog(@"bannerViewActionDidFinish called");
        [[UIApplication sharedApplication] setStatusBarOrientation :(UIInterfaceOrientation)[[CCDirector sharedDirector] deviceOrientation]];
    }
//<-- Instance method deviceOrientation not found (return type defaults to id)

有什么问题?缺少要继承的任何类?

3 个答案:

答案 0 :(得分:1)

您需要继承CCNode,而不是NSObject

编辑此外,deviceOrientation不是CCDirector的成员,那你为什么假设它是?

答案 1 :(得分:1)

onEnter和onExit方法仅在从CCNode派生的类中可用。你的类是NSObject的子类。

如果你手动发送onEnter / onExit消息,只需删除对super onXXX的调用,因为它是多余的。

答案 2 :(得分:0)

警告是存在的,因为您调用的方法(可能在您的超类@implementation中实现)在@interface中未公开显示。只需在超类.h文件中声明它们。

- (UIDeviceOrientation)deviceOrientation;
- (void)onExit;
- (void)onEnter;

如果您不希望它们公开显示,请在子类.m文件的类别中声明它们,因为您知道它们存在。