內: -
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
我不太清楚您的意思,但我看到您接受了答案,所以我想您會找到解決方案。 –