我有用于 UITabBarController 视图管理的MainController类。
当我尝试从 ViewController 显示我的 TabBarController 时 - 它显示清晰的屏幕。:-( 我只能从 __AppDelegate 显示我的 TabBarController。=)
如何从基于 UIViewController 的视图中显示 TabBarController?=)
请帮帮我。十分感谢。=)
// MainController.h
@interface MainController : UIViewController {
IBOutlet UITabBarController * tabBarController;
}
@property (nonatomic, retain) IBOutlet UITabBarController * tabBarController;
@end
我有 MyTestAppDelegate:
// MyTestAppDelegate.h
#import "MainController.h"
@class MainController;
@interface MyTestAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MainController * mController;
IBOutlet UIViewController * viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) MainController * mController;
@property (nonatomic, retain) IBOutlet UIViewController * viewController;
@end
// MyTestAppDelegate.m
#import "MyTestAppDelegate.h"
@implementation MyTestAppDelegate
@synthesize window, mController, viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
MainController * mc = [[MainController alloc] initWithNibName:@"MainView" bundle:nil];
self.mController = mc;
[mc release];
[window addSubview:[self.viewController view]];
[[viewController view] addSubview:[mController.tabBarController view]];
[window makeKeyAndVisible];
}
@end