您好,我正在尝试制作一个简单的游戏,其中的游戏是Sprite Kit场景,但是菜单和游戏屏幕都在故事板上。如何从场景切换到UIView?
使用以下方法:(我假设您有一个rootViewController,以便您可以呈现视图,并且您希望呈现的View在Storyboard中具有标识符,以便您可以实例化它们)
例子:
//The method which presents the view you wish to display:
-(void)presentUIView{
UIViewController *myview = [[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil]instantiateViewControllerWithIdentifier:@"MyView"];
[self.view.window.rootViewController presentViewController:myView animated:YES completion:nil];
}
//And then when you wish to dismiss the view to go back (called inside the View):
-(void)dismissItself:(id)sender{
[self dismissViewControllerAnimated:YES completion:nil];
}
让我知道是否有效
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句