Ios 已将无法识别的选择器发送到实例|目标C

Ios 已将无法识别的选择器发送到实例|目标C,ios,objective-c,iphone,Ios,Objective C,Iphone,应用程序在启动时崩溃,控制台中出现以下错误: 由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:“-[Chartboost ShowInterstitual]: 已将无法识别的选择器发送到实例0x7f844c9b74e0' 我的代码是: #import "cocos2d.h" #import "AppDelegate.h" #import "IntroLayer.h" #import "AppSpecificValues.h" #import <

应用程序在启动时崩溃,控制台中出现以下错误:

由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:“-[Chartboost ShowInterstitual]: 已将无法识别的选择器发送到实例0x7f844c9b74e0'

我的代码是:

#import "cocos2d.h"

#import "AppDelegate.h"
#import "IntroLayer.h"
#import "AppSpecificValues.h"
#import <RevMobAds/RevMobAds.h>

#import <Chartboost/Chartboost.h>


@implementation AppController
@synthesize gameCenterManager=gameCenterManager_, currentLeaderBoard=currentLeaderBoard_;
@synthesize window=window_, navController=navController_, director=director_;
@synthesize cb;
@synthesize nScore;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Create the main window
    window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Create an CCGLView with a RGB565 color buffer, and a depth buffer of 0-bits
    CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
                                   pixelFormat:kEAGLColorFormatRGB565   //kEAGLColorFormatRGBA8
                                   depthFormat:0    //GL_DEPTH_COMPONENT24_OES
                            preserveBackbuffer:NO
                                    sharegroup:nil
                                 multiSampling:NO
                               numberOfSamples:0];

    director_ = (CCDirectorIOS*) [CCDirector sharedDirector];

    director_.wantsFullScreenLayout = YES;

    // Display FSP and SPF
//  [director_ setDisplayStats:YES];

    // set FPS at 60
    [director_ setAnimationInterval:1.0/60];

    // attach the openglView to the director
    [director_ setView:glView];

    // for rotation and other messages
    [director_ setDelegate:self];

    // 2D projection
    [director_ setProjection:kCCDirectorProjection2D];
//  [director setProjection:kCCDirectorProjection3D];

    // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
    if( ! [director_ enableRetinaDisplay:YES] )
        CCLOG(@"Retina Display Not supported");

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
    // You can change anytime.
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

    // If the 1st suffix is not found and if fallback is enabled then fallback suffixes are going to searched. If none is found, it will try with the name without suffix.
    // On iPad HD  : "-ipadhd", "-ipad",  "-hd"
    // On iPad     : "-ipad", "-hd"
    // On iPhone HD: "-hd"
    CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
    [sharedFileUtils setEnableFallbackSuffixes:NO];             // Default: NO. No fallback suffixes are going to be used

    [sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"];      // Default on iPhone RetinaDisplay is "-hd"
    [sharedFileUtils setiPadSuffix:@"-ipad"];                   // Default on iPad is "ipad"
    [sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipad-hd"];   // Default on iPad RetinaDisplay is "-ipadhd"
    // Assume that PVR images have premultiplied alpha
    [CCTexture2D PVRImagesHavePremultipliedAlpha:YES];

    self.nScore = 0;

    //Revmobs
    [RevMobAds startSessionWithAppID:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"RevMobAPI"]];

    // and add the scene to the stack. The director will run it when it automatically when the view is displayed.
    [director_ pushScene: [IntroLayer scene]]; 

    [self initGameCenter];

    // Create a Navigation Controller with the Director
    navController_ = [[UINavigationController alloc] initWithRootViewController:director_];
    navController_.navigationBarHidden = YES;

    // set the Navigation Controller as the root view controller
//  [window_ addSubview:navController_.view];   // Generates flicker.
    [window_ setRootViewController:navController_];

    // make main window visible
    [window_ makeKeyAndVisible];

    return YES;
}

-(void) lunchRevmobADLink
{
    [[RevMobAds session] openAdLinkWithDelegate:self];
}

- (void) setUpRevMob {
    [[RevMobAds session] showFullscreen];
}

-(void) launchChartboost
{
         // Initialize the Chartboost library
        [Chartboost startWithAppId:@"53be6ed01873dc9741aafa"
                      appSignature:@"fcd1715a73c97b22c5ad557323a59d7348476"
                          delegate:self];

    // Begin a user session. This should be done once per boot
    [cb startSession];

    [cb cacheInterstitial];

    [cb cacheMoreApps];
}

-(void) showChartboostInterestitial
{
    // Show an interstitial
    [[Chartboost sharedChartboost] showInterstitial];
}

-(void) showChartboostMoreApps
{
    [[Chartboost sharedChartboost] showMoreApps];
}

// Supported orientations: Landscape. Customize it for your own needs
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}


// getting a call, pause the game
-(void) applicationWillResignActive:(UIApplication *)application
{
    if( [navController_ visibleViewController] == director_ )
        [director_ pause];
}

// call got rejected
-(void) applicationDidBecomeActive:(UIApplication *)application
{
    if( [navController_ visibleViewController] == director_ )
        [director_ resume];

    [self launchChartboost];

#ifdef FREE_VERSION
    [self showChartboostInterestitial];
    [self setUpRevMob];
    [self hideAdBanner:YES];

#endif
}
#导入“cocos2d.h”
#导入“AppDelegate.h”
#导入“IntroLayer.h”
#导入“AppSpecificValues.h”
#进口
#进口
@应用控制器的实现
@综合gameCenterManager=gameCenterManager,CurrentLeadboard=CurrentLeadboard;
@综合窗口=窗口,导航控制器=导航控制器,控制器=控制器;
@合成炭黑;
@合成nScore;
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
//创建主窗口
窗口\=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]边界]];
//使用RGB565颜色缓冲区和0位深度缓冲区创建CCGLView
CCGLView*glView=[CCGLView viewWithFrame:[窗口边界]
像素格式:kEAGLColorFormatRGB565//kEAGLColorFormatRGBA8
深度格式:0//GL\U深度\U组件24\U OES
巴弗:没有
共享组:无
多重取样:否
样本数:0];
董事(CCDirectorIOS*)[CCDirector sharedDirector];
director.wantsFullScreenLayout=是;
//显示FSP和SPF
//[导演uuSetDisplayStats:是];
//将FPS设置为60
[director_uuu设置动画间隔:1.0/60];
//将openglView附加到控制器
[director_uusetview:glView];
//用于旋转和其他消息
[主任/代表:自我];
//二维投影
[director_uuuuSetProjection:KCCD director Projection2D];
//[director setProjection:KCCD director Projection3D];
//在iPhone 4上启用高分辨率模式(视网膜显示),并在所有其他设备上保持低分辨率
如果(![director\uuuEnableRetinaDisplay:是])
CCLOG(@“视网膜显示不受支持”);
//PNG/BMP/TIFF/JPEG/GIF图像的默认纹理格式
//它可以是RGBA8888、RGBA4444、RGB5_A1、RGB565
//你可以随时改变。
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
//如果未找到第一个后缀,并且启用了回退,则将搜索回退后缀。如果未找到任何后缀,则将尝试使用不带后缀的名称。
//在iPad HD上:“-ipadhd”、“-iPad”、“-HD”
//在iPad上:“-iPad”、“-hd”
//在iphonehd上:“-HD”
CCFileUtils*sharedFileUtils=[CCFileUtils sharedFileUtils];
[sharedFileUtils SetEnableFallbackSuffix:否];//默认值:否。不会使用任何回退后缀
[sharedFileUtils SetIPhoneRetinadDisplaySuffix:@“-hd”];//iPhone RetinaDisplay上的默认值为“-hd”
[sharedFileUtils setiPadSuffix:@“-ipad”];//ipad上的默认值为“ipad”
[sharedFileUtils setiPadRetinaDisplaySuffix:@“-ipad hd”];//ipad RetinaDisplay上的默认值为“-ipadhd”
//假设PVR图像具有预乘alpha
[CCTexture2D PVrimageShavePremultipledAlpha:是];
self.nScore=0;
//暴徒
[RevMobAds startSessionWithAppID:[[NSBundle mainBundle]objectForInfoDictionaryKey:@“RevMobAPI”];
//并将场景添加到堆栈中。当视图显示时,控制器将自动运行该场景。
[director_uuPushScene:[IntroLayer scene]];
[自我中心];
//使用控制器创建导航控制器
navController_U9=[[UINavigationController alloc]initWithRootViewController:director_U9];
navController_u2;navigationBarHidden=是;
//将导航控制器设置为根视图控制器
//[窗口\添加子视图:导航控制器\视图];//生成闪烁。
[窗口\设置根视图控制器:导航控制器\];
//使主窗口可见
[window_uu;makeKeyAndVisible];
返回YES;
}
-(无效)午餐套餐MobadLink
{
[[RevMobAds session]openAdLinkWithDelegate:self];
}
-(无效)setUpRevMob{
[[RevMobAds会话]全屏显示];
}
-(无效)启动
{
//初始化Chartboost库
[Chartboost startWithAppId:@“53be6ed01873dc9741aafa”
应用签名:@“FCD1715A7397B22C5AD557323A59D7348476”
代表:自我];
//开始一个用户会话。这应该在每次引导时进行一次
[cb startSession];
[间质性];
[cb cacheMoreApps];
}
-(无效)ShowChartBoostInterestial
{
//显示间隙
[[Chartboost sharedChartboost]ShowInterstitual];
}
-(无效)showChartboostMoreApps
{
[[Chartboost sharedChartboost]showMoreApps];
}
//支持方向:景观。根据自己的需要定制
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
返回UIInterfaceOrientationSportRait(interfaceOrientation);
}
//接到电话,暂停比赛
-(无效)应用程序将重新签名:(UIApplication*)应用程序
{
如果([navController\uuVisibleViewController]==控制器)
[导演暂停];
}
//电话被拒绝了
-(无效)应用IDBECOMEACTIVE:(UIApplication*)应用
{
如果([navController\uuVisibleViewController]==控制器)
[董事简历];
[自动启动];
#ifdef免费版
[自我表现];
[自我设置RevMob];
[自我隐藏横幅:是];
#恩迪夫
}
和其他代码。 我试了很多东西!所以我现在问你,我如何解决这个问题???
谢谢,这是事先准备好的

您正在实例上调用showInterstitial,尽管它是一个类方法。它应该类似于
[Chartboost ShowInterstitual…

,因为您没有尝试以正确的方式显示Interstitual:

  • 要显示静态或间隙视频广告,请执行以下操作:
  • 你做这件事的方式是r
    // Show interstitial at location HomeScreen. See Chartboost.h for available location options.
    [Chartboost showInterstitial:CBLocationHomeScreen];