3.3.2版本如何在iOS二级页面显示游戏?

3.3.X有个问题,底层渲染cocos到View的时候,取的是当前应用window的view。
官方写法是:

CGRect bounds = [[UIScreen mainScreen] bounds];
self.window   = [[UIWindow alloc] initWithFrame:bounds];

// Should create view controller first, cc::Application will use it.
_viewController                           = [[ViewController alloc] init];
_viewController.view                      = [[View alloc] initWithFrame:bounds];
_viewController.view.contentScaleFactor   = UIScreen.mainScreen.scale;
_viewController.view.multipleTouchEnabled = true;
[self.window setRootViewController:_viewController];

// cocos2d application instance
game = new Game(bounds.size.width, bounds.size.height);
game->init();

[self.window makeKeyAndVisible];

这种写法适用于启动就展示游戏界面,但我们想实现的是在UINavigationController的二级页面展示游戏,但发现会Crash:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer setFramebufferOnly:]: unrecognized selector sent to instance 0x283603260' terminating with uncaught exception of type NSException

把0x283603260打印出来发现这是CALayer,而不是CAMetalLayer:

(lldb) po 0x283603260
<CALayer:0x283603260; name = "VC:UINavigationController"; position = CGPoint (422 195); bounds = CGRect (0 0; 844 390); delegate = <UILayoutContainerView: 0x10790b280; frame = (0 0; 844 390); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x28384ec70>; layer = <CALayer: 0x283603260>>; sublayers = (<CALayer: 0x283601960>, <CALayer: 0x283603100>); opaque = YES; masksToBounds = YES; allowsGroupOpacity = YES; transform = CATransform3D (1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1); name = VC:UINavigationController>

通过断点发现设置DeviceInfo的时候,windowHandle是UINavigationController的view,导致了这个问题


所以,3.3.2版本如何在iOS二级页面显示游戏呢?