I have two parts to my project. Part one is made in the storyboard, and the second is an SKView. How can I go from my second part in the SKView back to the main UIView?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Create custom
ViewController
: File - New - File - Objective-C class. Enter a name:GameSceneViewController
. Subclass ofUIViewController
.Override
viewWillAppear
method:-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; GameScene *scene = [[GameScene alloc] initWithSize:self.view.bounds.size]; scene.scaleMode = SKSceneScaleModeAspectFill; [self.skView presentScene:scene]; }
skView
property will be anIBOutlet
forSKView
. Also make sure you've imported SpriteKit framework:#import <SpriteKit/SpriteKit.h>
Add new
ViewController
to the storyboard.In the Identity inspector enter a custom class for the added ViewController:
GameSceneViewController
Add a subview to a root view:
In the Identity inspector enter a custom class for the added View:
SKView
Create an
IBOutlet
for the addedSKView
.
Now you should be able to use segues for switching between ViewControllers