2012-12-13 34 views
0

我有一個登錄屏幕視圖和5個選項卡在app.I想當我完成登錄屏幕,它應該移動到標籤視圖(5)。這一旦登錄任務完成後,我必須除去視圖並添加tab..how這樣做的另一個視圖控制器...DidFinishLoading view change

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController]; 


self.window.rootViewController = nav; 
[self.window makeKeyAndVisible]; 
return YES; 
} 

像這樣,我移到登錄視圖...現在怎麼登錄和移動完成後刪除到tab1,tab2,tab3,tab4,tab5

+0

發現這個鏈接我的答案可能是幫助給你http://stackoverflow.com/a/13857343/510814 – Senthilkumar

+0

http://stackoverflow.com/questions/13856933/tabbar-in-second-view/13857070#13857070 – Rajneesh071

回答

1

最初你作爲子視圖添加firstViewControlleraddDelegate.window,然後buttonClick你可以刪除你的navController,並添加tabBarControllerappDelegate.window

按照我的回答,效果更佳Link

+0

hi..need一個小幫助 – Christien

+0

..... ............ – Rajneesh071

+0

只需2分鐘...發送 – Christien

1

您可以將您的UITabBarController作爲您的初始視圖。在那裏你可以檢查你是否需要登錄,或者如果你自動登錄。如果您需要到登錄界面,只需用一個模式SEGUE顯示登錄查看並關閉它,當登錄完成。

+0

嘿whets這種模式seque ..我不是知道這個...如何使用這個 – Christien

+0

@Ch ristien你應該看看關於基本故事板[此雷Wenderlich教程](http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2)。在這部分2中,您可以找到什麼是模態輪迴。 – amb

2

您可以在AppDelegate中創建以下方法在2個導航控制器之間切換。然後

+ (AppDelegate *)sharedDelegate 
{ 
    return (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
} 

+ (void)showLogin { 
    AppDelegate *selfInstance = [self sharedDelegate]; 

    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController]; 
    selfInstance.window.rootViewController = nav; 

} 

+ (void)showTabs { 
    AppDelegate *selfInstance = [self sharedDelegate]; 

    self.viewController2 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil]; 
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController2]; 
    selfInstance.window.rootViewController = nav; 
} 

你didFinishLaunchingWithOptions方法應該是這樣的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    self.window.backgroundColor = [UIColor whiteColor]; 
    [self.window makeKeyAndVisible]; 

    if(isLoggedIn){ 
     [AppDelegate showLogin]; 
    } else { 
     [AppDelegate showTabs]; 
    } 

    return YES; 
} 
從任何地方

然後在你應用程式,你可以這樣做:

[AppDelegate showTabs]; 

讓我知道如果你需要幫助實現它。