ios - 需要从呈现的 UINavigationController 中返回到呈现的 UIViewController

标签 ios uiviewcontroller uinavigationcontroller xib uistoryboard

在 MyMainViewController 中,我展示了一个这样的导航 Controller :

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UINavigationController* nc = [storyboard instantiateViewControllerWithIdentifier:@"NAVIGATION_CONTROLLER_ID"];
[self presentViewController:nc animated:YES completion:nil];

稍后,我需要从 UINavigationController 的 View 层次结构中的某处返回到 MyMainViewController。我该怎么做?

(注意:MyMainViewController 是在 .XIB 中定义的,而不是在定义 UINavigationController 及其子级的 Storyboard中。)

最佳答案

听起来您已经模态呈现了一个您想要删除的 NavController。模态呈现的 VC 可以自行移除。

在 NavController 的某处添加:

[self dismissViewControllerAnimated:YES completion:^{
    NSLog(@"Dismissed nav controller modally");
}]

关于ios - 需要从呈现的 UINavigationController 中返回到呈现的 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23658896/

相关文章:

ios - 何时调用 [clLocationManager stopUpdatingLocation]

ios - NSIndexpath.item 与 NSIndexpath.row

iphone - objective-c 中的 self.propertyName 与 _propertyName

iphone - 将实例传递给另一个 View Controller 后为 "message sent to deallocated object"

ios - 来自 NSObject 类的 MFMailComposeViewController 显示问题 - iOS

ios - 如何在 Swift 中从不同的 ViewController 重新加载 TableView 中的数据

swift - 呈现 Controller 时呈现加载图像的延迟

iphone - 为所有 ViewController 定制导航 Controller

iOS 获取 UINavigationBar 的后退按钮以设置辅助功能属性

ios - 导航 Controller 工具栏按钮问题 - Xcode