代码之家  ›  专栏  ›  技术社区  ›  Hanz Cheah

目标C:后退按钮在AppsDelegate显示/按下视图控制器后消失

  •  0
  • Hanz Cheah  · 技术社区  · 7 年前

    下面的图片是我的故事板,我希望在 AppDelegate>下面是我的代码,位于 AppDelegate I manage to present the Expending VC when called.

    uiStoryboard*sb=[uiStoryboard StoryboardWithName:@“main”bundle:nil];
    uiviewController*vc=[sb instantialiviewControllerWithIdentifier:@“即将推出”];
    uinavigationcontroller*nv=[[uinavigationcontroller alloc]initwithrootviewcontroller:vc];
    nv.modalTransitionStyle=uimodalTransitionStyleFlipHorizontal;
    [self.window.rootviewcontroller presentviewcontroller:nv animated:yes completion:nil];
    

    在即将到来的VC上,我设法展示了标题和背景色的导航栏。我的后退按钮是自动生成的。

    —(void)viewwillappear:(bool)animated{
    
    self.navigationcontroller.navigationbar.hidden=否;
    
    [self.navigationitem sethidesbackbutton:false];
    //====显示导航栏===
    [self.navigationcontroller.navigationbar backgroundimage:nil forbarmetrics:uibarmetricsDefault];
    self.navigationcontroller.navigationbar.shadowImage=nil;
    
    //===将导航设置回<颜色
    self.navigationcontroller.navigationbar.tintcolor=[uicolor whitecolor];
    [self.navigationcontroller.navigationbar setbartingtcolor:[uicolor graycolor];
    //===设置导航栏文本颜色
    [self.navigationcontroller.navigationbar
    settitletextattributes:@nsforegroundcolorattributename:[uicolor whitecolor]];
    self.navigationcontroller.navigationbar.transparent=no;
    

    }

    应用程序委托

    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];
    

    即将到来的风险投资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;
    

    }

    2 回复  |  直到 7 年前
        1
  •  1
  •   Prashant Tukadiya    7 年前

    那你期待什么呢?

    只有当您按下 UpcomingVC 从现有的视图控制器 记住,只要在故事板中使用导航栏,现在就会自动显示backbutton。

    可以创建全视图控制器层次结构

    upcomingvc公司 HomeVC 然后你可以设置 家庭风险投资 作为嵌入的根视图控制器 UINavigationController 下一行你可以推 upcomingvc公司 动画为假

        2
  •  0
  •   Khushal iOS    7 年前

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

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

    您必须注册NIB。