内: -
Appdelegate.h
#import <UIKit/UIKit.h>
@class StartingViewController;
@interface Appdelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
StartingViewController *viewController;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet StartingViewController *viewController;
@property (nonatomic,retain) UITabBarController *tabBarController;
-(void)addTabBarToView;
@end
应用delegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
[self addTabBarToView];
return YES;
}
-(void)addTabBarToView{
FirstController *first = [[FirstController alloc] initWithNibName:@"FirstController" bundle:nil];
first.title = @"First";
SecondController *second = [[SecondController alloc] initWithNibName:@"SecondController" bundle:nil];
second.title = @"Second";
ThirdController *three = [[ThirdController alloc] initWithNibName:@"ThirdController" bundle:nil];
first.title = @"Third";
Forthcontrooler *Four4 = [[Forthcontrooler alloc] initWithNibName:@"Forthcontrooler" bundle:nil];
second.title = @"Secfor";
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:first];
UINavigationController *navigationController2 = [[UINavigationController alloc]initWithRootViewController:second];
UINavigationController *navigationController3 = [[UINavigationController alloc] initWithRootViewController:three];
UINavigationController *navigationController4 = [[UINavigationController alloc]initWithRootViewController:Four4];
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController1,navigationController2,navigationController3,navigationController4,nil];
[window addSubview:tabBarController.view];
}
您的建议似乎很有希望,但我无法显示它。你能否解释一点细节 - 可能是一步一步来的。我非常感谢。 – Sivon
我在UITabbarcontroller中嵌入了四个UINavigationController,然后将一个UITableViewcontroller连接到每个导航控制器。但仍然没有在UIviewcontroller中显示标签栏的运气(在单击表格视图单元格时出现在视图中) – Sivon
我不太清楚您的意思,但我看到您接受了答案,所以我想您会找到解决方案。 –