【问题标题】:Questions while using presentModalViewController使用 presentModalViewController 时的问题
【发布时间】:2013-05-19 03:57:08
【问题描述】:

在我的应用程序中,我尝试使用该功能 [self.navigationCotroller presentModalViewController:nextVC Animation:YES]; 但是,当它进入下一个视图时,子视图会占据整个屏幕(当然是这样) 问题是,我如何添加引导视图返回的条形按钮?

我尝试过使用

  1. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"back" style:UIBarButtonItemStyleDone target:self action:@selector(Go)];
    

    在函数viewdidLoad中,但没有工作,没有显示栏甚至按钮

  2. UINavigationBar *bb =  [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)];
    self.NVBar = bb;
    [self.view addSubview:bb];
    

但是,我不知道如何将 barbutton 添加到新的 navigationBar ---NVBar

你愿意给我一个解决方案吗?

【问题讨论】:

    标签: iphone view


    【解决方案1】:

    您需要弹出新的视图控制器才能自动包含导航栏。

    在视图控制器中,您的代码在上面,

    //*** Hook up four buttons to these actions and play around with it for a 
    //*** better sense of what is going on.    
    //*** JSBViewController is the name of my test class
    //*** You should use your ViewController class that you are currently coding so
    //*** you can see the difference of pop/push versus present/dismiss inside of a            
    //*** navigation controller
    -(IBAction)push:(id)sender
    {
      JSBViewController * viewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([JSBViewController class])];
      [self.navigationController pushViewController:viewController animated:YES];
    }
    -(IBAction)pop:(id)sender
    {
      [self.navigationController popViewControllerAnimated:YES];
    
    }
    -(IBAction)present:(id)sender
    {
      JSBViewController * viewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([JSBViewController class])];
      [self presentViewController:viewController animated:YES completion:nil];
    }
    -(IBAction)dismiss:(id)sender
    {
      [self dismissViewControllerAnimated:YES completion:nil];
    }
    

    对于您要查找的行为,您将需要使用推送方法
    [self.navigationController pushViewController:viewController animated:YES];

    【讨论】:

      【解决方案2】:

      如果您使用[self.navigationController pushViewController:picker animated:YES]; 推送您的nextVC,那么导航栏应该保持在顶部。然后你可以用 ` [self.navigationController popViewControllerAnimated:YES]; 弹回来;

      使用导航栏从模态视图返回是非常不同寻常的。 `

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多