2017-04-20 12 views
-1

こんにちは、私はこのコードを使用して、新しいcontorllerにちょうどコードとsegueなしで移動しました。ナビゲーションバーがpresentViewControllerの後に表示されない

UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"]; 
[self presentViewController:vc animated:YES completion:nil]; 

次のビューでナビゲーションバーまたはタイトルバーを表示するにはどうすればよいですか?あなたはナビゲーションバーをしたい場合

答えて

1

あなたは以下のようにNavigationControllerを提示する必要があります。

UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:ContactUSVCID]; 
UINavigationController *objNav = [[UINavigationController alloc] initWithRootViewController:vc]; 
[self presentViewController:objNav animated:YES completion:nil]; 
1

、あなたは

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; 


     SecondViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerB"]; 
    /********if dont have navigation bar***********/ 
UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"]; 
[self presentViewController:initialNavigationController animated:YES completion:nil]; 

/**********他************* /存在しないプッシュする必要が

[[self navigationController] pushViewController:vc animated:YES]; 
1

埋め込みナビゲーションコントローラやストーリーボードIDでのご使用のViewControllerナビゲーションコントロールにこのコードを使用してください。

UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"]; 
[self presentViewController:initialNavigationController animated:YES completion:nil]; 
1

ビューコントローラを表示すると、常にフルスクリーンで表示されます。 試用版

UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"]; 
[self presentViewController:navigationController animated:YES completion:nil]; 
関連する問題