【问题标题】:Navigation bar is showing in storyboard but not simulator导航栏显示在情节提要中,但不显示在模拟器中
【发布时间】:2023-03-17 20:46:01
【问题描述】:

以下是我的故事板,

ViewController(CaseInfo 或 VC2)显示导航栏

http://i.imgur.com/nQqj1IQ.png

但在我的模拟器中,导航栏不显示!

在 VC1(案例列表)中: 我让VC1成为导航控制器的rootView

我通过选择“推送”选项将 VC1 链接到 VC2

然后我在点击VC1的表格项时使用代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    CaseList *tagEditor = [self.storyboard instantiateViewControllerWithIdentifier:@"CaseInfo"];
    [self presentViewController:tagEditor animated:YES completion:nil];
}

但是VC2中的导航栏不显示

请帮帮我...

谢谢!!

-

顺便说一句

我也使用VC2(CaseInfo)中的代码

- (void)viewWillDisappear:(BOOL)animated
{
   [super viewWillAppear:animated];
   [self.navigationController setNavigationBarHidden:NO       animated:animated];
}

【问题讨论】:

    标签: ios objective-c uitableview uinavigationcontroller uinavigationbar


    【解决方案1】:

    在您的代码中,由于您已将 VC2 和 VC1 与 segue 链接

    你只需要开火

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        [self performSegueWithIdentifier:@"segueid" sender:nil];
    }
    

    然后在prepareForSegue,传递一些数据。

    或者

    你可以删除VC2和VC1之间的segue

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        CaseList *tagEditor = [self.storyboard instantiateViewControllerWithIdentifier:@"CaseInfo"];
        [self.navigationController pushViewController:tagEditor animated:true];
    }
    

    【讨论】:

    • 谢谢!您立即解决了我的问题,并节省了我的时间:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多