您好我正在尝试制作一个简单的游戏,其中游戏是精灵套件场景,但屏幕上的菜单和游戏都在故事板中。如何从场景切换到UIView?
答案 0 :(得分:1)
使用以下方法:(我假设您有一个rootViewController,以便您可以呈现视图,并且您希望呈现的视图在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];
}
让我知道它是否有效