Intégrer la vue SDL dans UIViewController

Certains de la démo SDL que j'ai vu pour iOS, tout le rendu se produit dans SDL_Window plutôt que UIWindow . Cependant, comme la plupart des applications iOS sont modélisées sur la base d'une seule UIWindow. Je voudrais intégrer iOS avec SDL et intégrer la window de SDL (ou la vue de SDL) dans la vue d'un UIViewController. Comment cela est-il accompli?

J'ai posté mes questions ici et vois aussi le commentaire suivant par michelleC indiquant ce qui suit mais je ne sais pas comment coder ce que michelleC a mentionné. Je n'ai pas la permission de postr / répondre sur leur forum.

Il est assez facile d'get la window sdl et d'y append des controllers de vue, ou d'get la vue sdl encapsulée et de l'append à un controller de vue.

Ce que j'ai fait jusqu'à maintenant modifiait SDL_uikitviewcontroller.m pour repositionner / resize la vue de SDL_Window:

 - (void)viewDidLayoutSubviews { CGRect newFrame = self.view.frame; newFrame.size.height = newFrame.size.height - 100; newFrame.size.width = newFrame.size.width - 50; newFrame.origin.x = 25.0f; self.view.frame = newFrame; SDLUIKitDelegate *appDelegate = [SDLUIKitDelegate sharedAppDelegate]; [appDelegate embedView:self.view]; } 

Je passe ensuite cette vue à une fonction dans SDL_uikitappdelegate.m où elle appenda l'affichage de SDL_Window en tant que sous-vue de UIViewController. Cependant, mon erreur a été rencontrée.

 - (void) embedView:(UIView*)vw { [vw removeFromSuperview]; CGRect frame = vw.frame; frame.origin.x = 56.0f; vw.frame = frame; [self.window.rootViewController.view addSubview:vw]; } 2014-10-11 12:53:51.723 Happy[16403:614428] -[SDLUIKitDelegate window]: unrecognized selector sent to instance 0x7fbf11500d60 2014-10-11 12:53:51.725 Happy[16403:614428] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SDLUIKitDelegate window]: unrecognized selector sent to instance 0x7fbf11500d60' *** First throw call stack: ( 0 CoreFoundation 0x00000001115323f5 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000111e04bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000011153950d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000011149160f ___forwarding___ + 495 4 CoreFoundation 0x0000000111491398 _CF_forwarding_prep_0 + 120 5 Happy 0x000000010f227eb1 -[SDLUIKitDelegate embedView:] + 289 6 Happy 0x000000010f26f968 -[SDL_uikitviewcontroller viewDidLayoutSubviews] + 1400 7 UIKit 0x000000010fcee1cc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 572 8 QuartzCore 0x0000000111284f98 -[CALayer layoutSublayers] + 150 9 QuartzCore 0x0000000111279bbe _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 10 QuartzCore 0x0000000111279a2e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 11 QuartzCore 0x00000001111e7ade _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242 12 QuartzCore 0x00000001111e8bea _ZN2CA11Transaction6commitEv + 390 13 UIKit 0x000000010fc8adb0 -[UIApplication _sendOrderedOutContextsAndInvalidate:] + 99 14 UIKit 0x000000010fc8ad2b orderOutContextObserverCallout + 34 15 CoreFoundation 0x0000000111467347 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 16 CoreFoundation 0x00000001114672a0 __CFRunLoopDoObservers + 368 17 CoreFoundation 0x000000011145c9e4 CFRunLoopRunSpecific + 436 18 Happy 0x000000010f223667 UIKit_PumpEvents + 71 19 Happy 0x000000010f1b0b10 SDL_PumpEvents + 48 20 Happy 0x000000010f1b0b88 SDL_WaitEventTimeout + 56 21 Happy 0x000000010f1b0b4a SDL_PollEvent + 26 22 Happy 0x000000010f16d883 SDL_main + 195 23 Happy 0x000000010f227d3e -[SDLUIKitDelegate postFinishLaunch] + 46 24 Foundation 0x000000010f81ea75 __NSFireDelayedPerform + 387 25 CoreFoundation 0x000000011149a4e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 26 CoreFoundation 0x000000011149a0a5 __CFRunLoopDoTimer + 1045 27 CoreFoundation 0x000000011145d3dd __CFRunLoopRun + 1901 28 CoreFoundation 0x000000011145ca06 CFRunLoopRunSpecific + 470 29 GraphicsServices 0x00000001130209f0 GSEventRunModal + 161 30 UIKit 0x000000010fc75550 UIApplicationMain + 1282 31 Happy 0x000000010f227608 main + 328 32 libdyld.dylib 0x00000001121c6145 start + 1 33 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException 

Le problème était dû à mon code référençant une mauvaise variable. La ligne suivante dans embedView: doit être remplacée à la place:

[self.window.rootViewController.view addSubview: vw];

avec

[myWindow.rootViewController.view addSubview: vw];