2011-09-21 86 views
1

我對iPhone世界很陌生。我正在研究一個基於視圖的項目。我的第一個視圖有登錄頁面。當登錄成功時,它將轉到下一個視圖。 我想要實現的是,當我將在第二個視圖。將有一個tabbarcontroller有五個選項卡項目和第一個選項卡的視圖將visisble。當我點擊其他標籤時,我們會相應地獲得下一個視圖。如何在基於視圖的應用程序中的第二個視圖中放置tabbar控制器?

現在,如何在第二個視圖中放置一個標籤欄?

任何形式的幫助將不勝感激。

回答

3

使用[自我presentModalViewController顯示在你的TabBar控制器登錄控制器。成功登錄後,請解僱它。

+0

謝謝,但這將創建我的登錄tabbar,我不想要。我的登錄會有所不同,登錄後下一個視圖將會有tabbar。希望我非常清楚我需要什麼。提前致謝。 – mH16

+0

你的意思是你的登錄不覆蓋整個屏幕?因爲這就是它應該做的。你可以發佈你用來展示模態控制器的代碼嗎? – mja

+0

在哪裏實現此代碼? – mH16

1

您需要創建一個ViewController,它是UITabBarViewController的子類。在nib中設計tabbar或查看此控制器的生命週期方法。

登錄目前新控制器後[自我presentModalViewController]

1
You need to implement your code as below. 
First create a controller class for login. 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    [self generateLoginScreen]; 

    [self removeLoginScreen]; // On login check implement this method or u can directly write the snippet here as well. 



    [self prepareControllersOnTabs]; //your tab controller code function 

    [self.window makeKeyAndVisible]; 
    return YES; 
} 

-(void) removeLoginScreen 
{ 
    [loginScreenViewController.view removeFromSuperview]; 
    self.window.rootViewController = self.tabBarController; 
    [loginScreenViewController release]; 
} 

-(void) generateLoginScreen 
{ 
    loginScreenViewController = [[LoginScreenController alloc] initWithNibName:@"LoginScreenController" bundle:[NSBundle mainBundle]]; 

    [self.window addSubview:self.loginScreenViewController.view]; 
} 

Hope this is exactly what u want. 
相關問題