objective-cxcodeviewcontrollertransit

Transit between view controllers using code


Im a new programmer and I am stuck with a problem. I simply want to transit from ViewController to NOViewController when the livesLeft reaches to 0.

(When you're dead, the "death"screen should appear) Big thanks in advance!

if (livesLeft == 0)
{
    //transit to NOViewController

}

Solution

  • if (livesLeft == 0)
    {
        NOViewController *NoLivesVC = [[UIStoryBoard storyboardWithName: @"Main" setBundle: nil] instantiateViewConrollerWithIdentifier: @"ViewControllerIndentifier"];
        // Do something
        [self presentViewController animated: YES completion:nil];
    
    }
    

    Hope this helps. I presume this is what you were asking.