2 developerwab developerWab 于 2013.04.24 11:05 提问

返回后视图的导航条消失了

使用 storyboard 创建了一个带有 navigation bar 的项目。其中有从ViewA点击一个按钮打开ViewB的功能,这一段实现了。然后我用一个取消键返回ViewA。在取消之后,返回ViewA成功了,但是导航条没有显示。而且是ViewA中有导航条,ViewB中没有。

请高手指点一下,谢谢。

View A:

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    EditViewController *viewController = (EditViewController *)[storyboard instantiateViewControllerWithIdentifier:@"EditViewController"];
    [self presentViewController:viewController animated:NO completion:NULL];

View B:

- (IBAction)cancelButtonPressed:(id)sender {
    if ( lables != NULL) {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        ScannerViewController *viewController = (ScannerViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ScannerViewController"];

        [self presentViewController:viewController animated:NO completion:NULL];

    }
    else{

        [self.navigationController popViewControllerAnimated:YES];
    }

1个回答

garaster
garaster   2013.04.24 16:14

实现self.navigationController弹出展现viewB。要用到presentviewcontroller 和dismissviewcontroller

[self dismissViewControllerAnimated:YES completion:nil];

根据你的情况最好用到UINavigationController

e.g

推出:

[self.navigationController pushViewController:viewController animated:YES];

关闭:

[self.navigationController popViewControllerAnimated:YES];
Csdn user default icon
上传中...
上传图片
插入图片