使用代码在视图控制器之间传输
Transit between view controllers using code
我是一名新程序员,但遇到了一个问题。
当 livesLeft 达到 0.
时,我只想从 ViewController 过渡到 NOViewController
(当你死了,"death"屏幕应该会出现)
非常感谢!
if (livesLeft == 0)
{
//transit to NOViewController
}
你是这个意思吗?
NOViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"storyboard_identifier"];
[self.navigationController pushViewController:secondView animated:YES];
是的有点!我真的是个新手,所以还没有了解导航控制器。但这解决了我的问题:
{
NOViewController *NOVC = [[NOViewController alloc]init];
[self presentViewController:NOVC animated:YES completion:^{
}];
非常感谢您的回复!
if (livesLeft == 0)
{
NOViewController *NoLivesVC = [[UIStoryBoard storyboardWithName: @"Main" setBundle: nil] instantiateViewConrollerWithIdentifier: @"ViewControllerIndentifier"];
// Do something
[self presentViewController animated: YES completion:nil];
}
希望这对您有所帮助。我想这就是你要问的。
我是一名新程序员,但遇到了一个问题。 当 livesLeft 达到 0.
时,我只想从 ViewController 过渡到 NOViewController(当你死了,"death"屏幕应该会出现) 非常感谢!
if (livesLeft == 0)
{
//transit to NOViewController
}
你是这个意思吗?
NOViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"storyboard_identifier"];
[self.navigationController pushViewController:secondView animated:YES];
是的有点!我真的是个新手,所以还没有了解导航控制器。但这解决了我的问题:
{
NOViewController *NOVC = [[NOViewController alloc]init];
[self presentViewController:NOVC animated:YES completion:^{
}];
非常感谢您的回复!
if (livesLeft == 0)
{
NOViewController *NoLivesVC = [[UIStoryBoard storyboardWithName: @"Main" setBundle: nil] instantiateViewConrollerWithIdentifier: @"ViewControllerIndentifier"];
// Do something
[self presentViewController animated: YES completion:nil];
}
希望这对您有所帮助。我想这就是你要问的。