ios - 将我的 NavigationController 与我的 ECSlidingViewController 一起使用

标签 ios objective-c uinavigationbar slidingmenu ecslidingviewcontroller

我想做什么


如果开始创建我的应用程序。我有一个 NavigationController 作为我的 rootViewController。当应用程序启动时,它将打开我的 LoginViewController。如果一切正常,我会在那里执行 Login-Procedure。我将启动我的 ECSlidingViewController。其中有一个菜单 (UITableView) 和一个MainView (UITableView)。

到这里为止一切正常。我可以滑动,它会显示我的菜单。现在问题开始了。当我按下一个菜单项时,它会完美地启动我的新 ViewController 并显示内容。但它仍然显示相同的 NavigationBar - 就像在 ECSlidingViewController 中一样。所以我无法告诉用户他在看什么,有时我还需要在 NavigationBar 中向他展示新选项。

问题


我该如何解决这个问题?我总是喜欢显示我实际使用的特定 ViewController 的 NavigationBar。如果你们有一些代码片段或如何处理这个问题的好主意。请在下面发表评论。

如果您需要代码片段或其他内容,请告诉我,我会上传!提前致谢!

代码


这就是我启动 ECSlidingMenu 的方式:

[self performSegueWithIdentifier:@"loginPush" sender:self.view];

这就是我将如何启动一个新的 ViewController:

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];

图片*


Structure of the Storyboard:

最佳答案

您想更改您的结构,使 ECSlidingViewViewController 成为 Root View Controller 。这可以从应用程序的启动开始,也可以在登录后切换根目录。滑动 Controller 的顶 View Controller 应该是一个导航 Controller ,你应该设置根并将其他 View Controller 插入该导航 Controller 。

您当前拥有的内容会破坏 View Controller 和导航 Controller 之间的链接,因为只有滑动 View Controller 会被插入堆栈及其标题(关于其 navigationItem 的任何内容都不会更改)。

可能最简单的解决方案是更改 Storyboard 中的初始 View Controller (更改为滑动 View Controller )。在这种情况下,登录 View 将显示为导航 Controller 的 Root View (这将是顶 View )。然后,在登录后你推送下一个 View Controller ,然后(在动画完成后)从导航堆栈中删除登录 View Controller 。

关于ios - 将我的 NavigationController 与我的 ECSlidingViewController 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18487301/

相关文章:

ios - 当管理对象在 moc A 中被删除时,它是否仍然存在于 moc B 中?

ios - 使用 MMDrawerConroller 如何禁用旋转是一些 ViewControllers?

objective-c - 非视网膜显示屏上扭曲的自定义导航按钮(使用可拉伸(stretch)图像方法)

swiftui - 在 SwiftUI 中设置导航栏项样式

html - iOS - HTML 源与在桌面版 Chrome 中检查元素时不同

iphone - 本地通知声音不起作用

ios - 协议(protocol) 'xxx' 只能用作通用约束,因为它具有 Self 或关联类型要求

objective-c - Alpha 使用 UIView animateWithDuration : instead of animating 立即改变

ios - 更改 IOS 7 状态栏内容颜色

ios - 为什么 ARKit MDLTransform 从相机变换中随机返回 0?