-[AppController window]: unrecognized selector sent to instance 0x280c24420'

2020-12-09 17:41:35 浏览数 (1)

bug显示问题: 最近在编译游戏工程的时候,对接了渠道的SDK,然后老是出现崩溃

代码语言:javascript复制
Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[AppController window]: unrecognized selector sent to instance 0x280c24420' 

崩溃效果图如下:

image.png

如果出现这个问题,那么首先恭喜你,不是渠道的SDK太旧了,不兼容版本,而是CP游戏工程太老了

解决方法如下:

1:游戏工程里APPcontroller.h文件要进行修改UIWindow
代码语言:javascript复制
@interface AppController : UIResponder <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate>
{
    RootViewController    *viewController;
    id reachAbilityObj;
    // id jpushObject;
}
//根window
@property (strong, nonatomic) UIWindow *window;

修改后效果图:

image.png

2:游戏工程里APPcontroller.m文件要进行修改对应的APPwindow

下面是我的代码,大家对应的代码不同,自己相对应修改

代码语言:javascript复制
_window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
//    window = [[UIWindow alloc] initWithFrame: winRect];

    CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [[UIScreen mainScreen] bounds]
                                     pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
                                     depthFormat: cocos2d::GLViewImpl::_depthFormat
                              preserveBackbuffer: NO
                                      sharegroup: nil
                                   multiSampling: NO
                                 numberOfSamples: 0 ];

    [eaglView setMultipleTouchEnabled:YES];
    
    // Use RootViewController manage CCEAGLView
    viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
    viewController.wantsFullScreenLayout = YES;
    viewController.view = eaglView;

image.png

3:游戏工程里main修改释放池
代码语言:javascript复制
#import <UIKit/UIKit.h>
#import "AppController.h"

int main(int argc, char *argv[]) {
    
    @autoreleasepool {
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppController class]));
        }
}

再次编译,即可编译成功,就不会崩溃了!

0 人点赞