views:

544

answers:

1

I have MainController class for UITabBarController's view managing.

When I try to display my TabBarController from ViewController - it display clear screen. :-( I could display my TabBarController only from __AppDelegate. =)

How can I display TabBarController from my UIViewController based view? =)

Please help me guys. Thank you a lot. =)

// MainController.h

@interface MainController : UIViewController {
    IBOutlet UITabBarController * tabBarController;
}
@property (nonatomic, retain) IBOutlet UITabBarController * tabBarController;
@end

I have 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
A: 

Documentation says that UITabBarController has to be on root level. See links and possible workarounds here: http://discussions.apple.com/thread.jspa?threadID=2190703&amp;tstart=0

I have posted full project with working code here, based on code on above thread: http://discussions.apple.com/thread.jspa?messageID=10708521&amp;#10708521

Simo Salminen