本人親測(cè)有效!絕對(duì)可靠!更多交流可以家魏鑫:lixiaowu1129斜纪,公重好:iOS過(guò)審匯總贫母,一起探討iOS相關(guān)技術(shù)!
bug顯示問(wèn)題:
最近在編譯游戲工程的時(shí)候盒刚,對(duì)接了渠道的SDK腺劣,然后老是出現(xiàn)崩潰
Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[AppController window]: unrecognized selector sent to instance 0x280c24420'
崩潰效果圖如下:
image.png
如果出現(xiàn)這個(gè)問(wèn)題,那么首先恭喜你因块,不是渠道的SDK太舊了橘原,不兼容版本,而是CP游戲工程太老了
解決方法如下:
1:游戲工程里APPcontroller.h文件要進(jìn)行修改UIWindow
@interface AppController : UIResponder <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate>
{
RootViewController *viewController;
id reachAbilityObj;
// id jpushObject;
}
//根window
@property (strong, nonatomic) UIWindow *window;
修改后效果圖:
image.png
2:游戲工程里APPcontroller.m文件要進(jìn)行修改對(duì)應(yīng)的APPwindow
下面是我的代碼涡上,大家對(duì)應(yīng)的代碼不同趾断,自己相對(duì)應(yīng)修改
_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修改釋放池
#import <UIKit/UIKit.h>
#import "AppController.h"
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppController class]));
}
}
image.png
再次編譯,即可編譯成功吓懈,就不會(huì)崩潰了歼冰!