presentViewController隐藏导航控制器(iOS7)

时间:2014-01-26 00:17:19

标签: ios

我希望我的3个视图中的每个视图都有一个“导航”按钮。当您单击该按钮时,它会打开一个具有3个按钮的模态视图。每个按钮(例如:视图1,视图2 ..)会将您带到相应的视图,但由于某种原因,在segue之后导航控制器(状态栏,标题等)被隐藏。

这就是我的行动:

mainNavController.h

- (IBAction)openUpcomingReleases:(id)sender {
    UpcomingReleasesViewController *upcomingReleases = [self.storyboard instantiateViewControllerWithIdentifier: @"upcomingReleases"];
    upcomingReleases.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:upcomingReleases animated:YES completion:nil];
}

感谢。

2 个答案:

答案 0 :(得分:3)

这里的一切都按预期工作。

导航控制器的导航栏仅显示该导航控制器包含的视图控制器。在这里,您将呈现一个模态视图。它不包含在导航控制器中。

如果您希望导航栏继续显示:

  • 如果它纯粹是一种风格问题,请在界面构建器中显示的模态场景上放置一个导航栏。
  • 如果您需要以模态方式呈现应包含在导航控制器中的视图,则需要提供导航控制器 - 而不是视图控制器。
  • 最后,如果您要呈现的视图旨在成为导航控制器导航堆栈的一部分,那么您需要使用推送而不是模态segue来呈现它。

答案 1 :(得分:1)

Embed a UINavigation controller to the upcomingReleases View Controller

and give StoryBoard Id for the navigation controller as upcomingReleasesNavi 

then write the code , it will present with Navigation bar.

- (IBAction)openUpcomingReleases:(id)sender {

                UIViewController *svc =[self.storyboard instantiateViewControllerWithIdentifier
:@"upcomingReleasesNavi"];

                svc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
                [self presentViewController:svc animated:YES completion:nil];
}
相关问题