因为,用户编辑问题,所以我再次给出答案。如果你想要带有 NavigationController 的 tabBar
在 AppDelegate.h 中定义生成UINavigationController *navController;
属性并在 appDelegate.m 中进行综合。
在 AppDelegate.m 中导入所有 ViewController 类
喜欢
#import "ViewController.h"
#import "Preview.h"
#import "Export.h"
#import "Settings.h"
#import "More.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
//Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController
ViewController * search = [[ViewController alloc] init];
UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];
Preview* nearby = [[Preview alloc] init];
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];
Export* map = [[Export alloc] init];
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];
Settings* aboutUs = [[Settings alloc] init];
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];
More* favorites = [[More alloc] init];
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];
NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];
tabBarController.viewControllers = controllers;
[self.window addSubview:tabBarController.view];
// self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
// self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
可能对你有帮助。