0

我是 iOS 开发的初学者。在我的应用程序中,RootView 通过按钮(在故事板中定义,push segue)跳转到子视图:A、B、C、D。我使用一些图像来触摸,以便子视图可以相互推送,即 B 控制器中的代码:

// jump to View C
[self.navigationController pushViewController:CView animated: YES];

C控制器中的代码,定义backButton点击显示RootView:

-(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        [self.navigationController popToRootViewControllerAnimated:NO];
    }
    [super viewWillDisappear:animated];
}

显示RootView是完美的,但顶部显示我在B控制器中定义的backButton和title。RootView 有一个图像标题。其他视图的标题在情节提要中设置。我现在能做什么?

4

1 回答 1

0

解决了,navigationBar也需要弹出:

-(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        // add this pop:
        [self.navigationController.navigationBar popNavigationItemAnimated:NO];
        [self.navigationController popToRootViewControllerAnimated:NO];
    }
    [super viewWillDisappear:animated];
}
于 2013-05-03T07:55:56.620 回答