您需要像这样在 AppDelegate 中添加导航控制器,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
在您的 ViewController 中,像这样导航,
self.countryViewController = [[CountriesViewController
alloc]initWithNibName:@"CountriesViewController" bundle:nil];
[self.navigationController pushViewController:self.countryViewController animated:YES];