2012-09-13 40 views
0

如何重定向到一個視圖的主視圖控制器。我目前在登錄頁面,現在我想加載PhotoMasterViewController。任何人都可以告訴我該怎麼做。如何從一個視圖重定向到主視圖控制器

+0

是你的MasterViewController的PhotoMasterViewController? – IronManGill

+0

嗨重定向意味着你想添加子視圖嗎?或通過目前的模式控制器或導航?你喜歡什麼添加... – Spynet

+0

我需要導航到用戶到PhotoMasterViewController頁面。任何幫助 –

回答

0

爲什麼不使用 「ModalViewController」

它比navigationController更好,你可以使用這樣

-(void)NextView:(id)sender 
{ 
PhotoMasterViewController *Photo = [[PhotoMasterViewController alloc]initWithNibName:@"PhotoMasterViewController" bundle:nil]; 
//enum, you can choose which style you like 
Photo.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:Photo animated:YES]; 
} 
0

在你masterViewController添加以下代碼,並使用pushViewController-

-(void)NextView:(id)sender 
{ 
PhotoMasterViewController *Photo = [[PhotoMasterViewController alloc]initWithNibName:@"PhotoMasterViewController" bundle:nil]; 
[self.navigationController pushViewController:Photo animated:YES]; 
} 
+0

: - 感謝您的幫助。但即時通訊新的iphone開發。所以實際上我對上面的代碼沒有多少了解。你能解釋一下如何做到這一點。 也在我的應用程序委託,我重定向用戶登錄屏幕。如果用戶正確輸入密碼,我想將它們導航到主頁面(PhotoMasterViewController)。 if(photoMasterViewController == nil) {photoMasterViewController = [[PhotoMasterViewController alloc] initWithNibName:@「PhotoMasterViewController」bundle:nil];這是我的代碼 ; } [self.view addSubview:photoMasterViewController.view]; –

+0

@DeepakPillai你可能已經創建了一個視圖回到你的PhotoViewController rite?所以添加一個方法在那個View.m文件中,你需要繼續回到你的PhotoViewController ..... – IronManGill

+0

感謝大家。我得到了我想要的代碼 UIViewController * rootController = [[MyWordSafeMasterViewController alloc] init]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:rootController]; [rootController release]; self_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window addSubview:_navigationController.view]; [self.window makeKeyAndVisible]; 也是這是正確的方法嗎? 再次感謝你的所有:) –

相關問題