【问题标题】:Objective-C: Back Button disappear after present/push ViewController from AppsDelegateObjective-C:从AppsDelegate呈现/推送ViewController后后退按钮消失
【发布时间】:2018-06-18 09:49:42
【问题描述】:

下面的图片是我的故事板,我希望在AppDelegate 展示Upcoming VC。下面是我在AppDelegate 的代码,我在调用时设法呈现Upcoming VC

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc=[sb instantiateViewControllerWithIdentifier:@"Upcoming"];
UINavigationController *nv = [[UINavigationController alloc] initWithRootViewController:vc];
nv.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.window.rootViewController presentViewController:nv animated:YES completion:nil];

Upcoming VC,我设法展示了navigationBar with title and background colour,但我的后退按钮< 仍然不见了。我的后退按钮是自动生成的。

-(void)viewWillAppear:(BOOL)animated{

    self.navigationController.navigationBar.hidden = NO;

    [self.navigationItem setHidesBackButton:FALSE];
    //====Make the navigation Bar appear===
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = nil;

    //=== Set the navigation Back < color
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setBarTintColor : [ UIColor grayColor]];
    //=== Set the navigation Bar text color
    [self.navigationController.navigationBar
    setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
    self.navigationController.navigationBar.translucent = NO;

}

请帮忙。

【问题讨论】:

    标签: ios objective-c uinavigationcontroller appdelegate back-button


    【解决方案1】:

    那你有什么期待呢?

    后退按钮仅在您从现有 ViewController 推送 UpcomingVC 时可见 请记住,仅在故事板中使用导航栏现在将自动显示后退按钮。

    您可以创建完整的视图控制器层次结构

    喜欢

    UpcomingVCHomeVC 推送,然后您可以将HomeVC 设置为嵌入在UINavigationController 中的根视图控制器,然后您可以推送到下一行 UpcomingVC 动画为假

    【讨论】:

      【解决方案2】:

      你可以试试这个 故事板到故事板

      ViewControllerName * next = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerName"];
      [self.navigationController pushViewController:next animated:YES];
      

      您必须注册笔尖。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-01
        • 2010-10-07
        • 1970-01-01
        • 2011-06-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多