0

我有用于 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
4

1 回答 1

0

文档说 UITabBarController 必须在根级别。在此处查看链接和可能的解决方法:http: //discussions.apple.com/thread.jspa ?threadID=2190703&tstart=0

我在这里发布了带有工作代码的完整项目,基于上面线程上的代码:http ://discussions.apple.com/thread.jspa?messageID=10708521昩

于 2009-12-08T20:15:50.870 回答