Objective-C:在AppsDelegate中显示/推送ViewController后,后退按钮消失

时间:2018-06-18 09:49:43

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

下面的图片是我的故事板,我希望在Upcoming VC展示AppDelegate。以下是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;

}

请帮忙。

Pic1

2 个答案:

答案 0 :(得分:1)

那么你期待什么?

仅当您从现有ViewController推送UpcomingVC时,

后退按钮才会显示 请记住,只需在故事板中使用导航栏,现在就会自动显示后退按钮。

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

喜欢

UpcomingVC已从HomeVC推出,然后您可以将HomeVC设置为UINavigationController中嵌入的根视图控制器,并将其设置为您可以推送的下一行 动态为假的UpcomingVC

答案 1 :(得分:0)

您可以输入 从StoryBoard到StoryBoard

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

您必须先注册笔尖。