2013-07-13 95 views
-1

我想知道如何在新視圖上顯示標籤控制器。iOS - 如何在新視圖上顯示標籤控制器

我有我的選項卡控制器3項:家庭,信息,幫助在回家

,有可能打開一個新的觀點,這種所謂的「測試版」的新觀點,但不顯示標籤控制器的按鈕,我不知道如何顯示標籤控制器,我不想要「測試版」作爲標籤項目雖然..

任何幫助將不勝感激。

這裏是一些代碼,我已經使用至今

//this is in appdelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    // Override point for customization after application launch. 
    UIViewController *viewController1 = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; 
    UIViewController *viewController2 = [[InformViewController alloc] initWithNibName:@"InformViewController" bundle:nil]; 
    UIViewController *viewController3 = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil]; 

    self.tabBarController = [[UITabBarController alloc] init]; 
    self.tabBarController.viewControllers = @[viewController1, viewController2, viewController3]; 
    self.window.rootViewController = self.tabBarController; 


    [self.window makeKeyAndVisible]; 
    return YES; 



//this opens the new view called beta 

@implementation HomeViewController 

-(IBAction)Showbeta 
{ 
    betaViewController *betaViewController = [[betaViewController alloc] initWithNibName:nil bundle:nil]; 
    [self presentViewController:betaViewController animated:YES completion:NULL];  
} 

//this is in betaviewcontroller 
@interface betaViewController() 

@end 

@implementation betaViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
     // self.window.rootViewController = self.tabBarController; --> this did not work 
    } 
    return self; 
} 
+0

我檢查了它是如何在appdelegate – 1303rajaryan1303

+0

中完成的,但它使用self.window.rootviewcontroller = self.tabbarcontroller; – 1303rajaryan1303

+0

我會建議編輯你的問題與你用來嘗試實例化UITabBar控制器的代碼。另外,你是使用故事板,XIB等? – Dan

回答

1

如果我理解正確的話,你需要爲標籤導航控制器,其根是國內VC視圖控制器。然後,當您想要顯示測試版視圖時,只需像其他任何導航控制器一樣將其推入,並將其保留在選項卡欄內。

所以,你應該你的代碼適應這樣的事情:

UIViewController *viewController1 = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; 
UIViewController *viewController2 = [[InformViewController alloc] initWithNibName:@"InformViewController" bundle:nil]; 
UIViewController *viewController3 = [[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil]; 

UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:viewController1] 

self.tabBarController = [[UITabBarController alloc] init]; 
//self.tabBarController.viewControllers = @[viewController1, viewController2, viewController3]; 
self.tabBarController.viewControllers = @[navController, viewController2, viewController3]; 
+0

謝謝你的建議幫助我實現了我想要做的事情。 – 1303rajaryan1303

0

可以聲明在AppDelegate類的tabController實例。 現在將您的主視圖控制器指定爲rootViewController。 點擊主屏幕上的按鈕,會出現一個新的視圖,它應該有一個tabViewController。因此,您現在應該將rootViewController設置爲: [[[[UIApplication sharedApplication]委託]窗口] .rootViewController = tabViewController;

+0

我不確定你在暗示什麼 – 1303rajaryan1303

+0

你使用故事板實現嗎? –

相關問題