2011-11-02 61 views

回答

4

有幾種方法。我假設你正在使用UINavigationController。如果是這樣,那麼你可以創建VC,並在你的父視圖控制器中執行此操作。

[self.navigationController pushViewController:viewController animated:YES] 
3

所以基本上你正在嘗試構建一個多視圖應用程序。有很多方法可以這樣做。卜我將列出3倍常見的 -

  1. [self.view insertSubview:newViewController.view atIndex:3];
  2. 使用UINavigationController
  3. 最後使用modalViewController - [self presentModalViewController:newViewController animated:YES];

在第二種方法,我用這個控制器沒有UINavigationTabBar。隱藏此導航欄&提供基於哪個[self.navigationController popViewControllerAnimated]應發生的自定義按鈕。

-1

我遇到了同樣的問題。用戶登錄後需要重定向到不同的頁面,否則默認情況下需要保留在主頁中。

這裏是代碼片段。

這裏

N_loginmsg = @"success"; 
    NSString *N_loginmsg = [[NSUserDefaults standardUserDefaults]objectForKey:@"remember_loginmsg"]; 
     NSString *storyboardId; 
     if (N_loginmsg != nil && [N_loginmsg isEqual:@"Success"]) 
     { 
      storyboardId = @"ListViewController"; 
     } 
     else 
     { 
      storyboardId = @"HomeViewController"; 
     } 
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil]; 
     UIViewController *initViewController = [storyboard instantiateViewControllerWithIdentifier:storyboardId]; 
     UINavigationController *mynav = [[UINavigationController alloc]initWithRootViewController:initViewController]; 
     self.window.rootViewController = mynav; 
     [self.window makeKeyAndVisible]; 
0
ViewController2 *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"viewController"]; 
[self.navigationController pushViewController:newView animated:YES]; 

在ViewController2 「身份檢查」 集故事情節的ID。

相關問題