UITabBarController *tabBarController=[[UITabBarController alloc]init];
tabBarController.delegate=self;
Screen1 *screen1=[[Screen1 alloc]init];
UINavigationController *nav2=[[UINavigationController alloc]screen1];
Screen2 *screen2=[[Screen2 alloc]init];
UINavigationController * nav3=[[UINavigationController alloc]initWithRootViewController:screen2];
UIWindow *samplewindow = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
NSArray *controllers=[NSArray arrayWithObjects:nav2,nav3, nil];
tabBarController.viewControllers=controllers;
[self.window addSubview:tabBarController.view];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:[NSBundle mainBundle]];
samplewindow.rootViewController = self.viewController;
[samplewindow addSubview:self.viewController.view];
[samplewindow makeKeyAndVisible];
在 AppDelegate.m 中添加此代码,然后它会正常工作。