How can I switch views programmatically in a view controller? (Xcode, iPhone)
问题 Have been struggling with this for a while, and can never seem to get a direct answer. Any help is appreciated! 回答1: If you're in a Navigation Controller: ViewController *viewController = [[ViewController alloc] init]; [self.navigationController pushViewController:viewController animated:YES]; or if you just want to present a new view: ViewController *viewController = [[ViewController alloc] init]; [self presentViewController:viewController animated:YES completion:nil]; 回答2: If you want to