如何通过整个iOS应用程序保留滑出侧边栏菜单 [英] How to persist a slide-out sidebar menu through entire iOS app

查看:145
本文介绍了如何通过整个iOS应用程序保留滑出侧边栏菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个既定的解决方案,用于创建和保留滑出边栏菜单(如在Facebook或Spotify上),以便它出现在iOS应用程序的任何视图中?我尝试过使用MMDrawerController,但是一旦我从初始视图中消失,我就会丢失边栏。我假设这是因为我正在转换整个viewController,而不仅仅是更改centerViewController。

Is there an established solution for how to create and persist a slide out sidebar menu (like on Facebook, or Spotify) so that it appears on any view in your iOS application? I've tried using MMDrawerController, but once i segue from the initial view, I lose the sidebar. I assume this is because I'm transitioning the entire viewController, and not just changing the centerViewController.

值得注意的是,我在项目中使用了故事板,并希望尽可能继续使用。

Of note, I am using a storyboard in my project, and would like to continue if possible.

推荐答案

如果我有一个我想要永久保留的GUI元素(或者出现并消失但是被多个视图控制器共享)那么我创建一个根查看控制器并向其添加持久性gui元素,并添加容器视图作为RVC主视图的子类,该视图覆盖整个屏幕大小。

If I have a GUI element that I want to persist permanently (or appear and disappear but be shared by multiple view controllers) then I create a root view controller and add the persistent gui elements to it and add a container view as a subclass of the RVC's main view which covers the entire size of the screen.

然后通常是什么应该是你的应用程序的rvc嵌入在这个容器视图中。

Then what ordinarily would have been your app's rvc is embedded within this container view.

在我发布的示例中,容器顶部有一个UILabel,当然可以是任何东西(包括整个视图层次结构,或其他容器视图,其中嵌入了另一个视图控制器,无论你想要什么)。您可以根据需要在整个程序的其余部分使其显示或消失,方法是根据需要创建/销毁它,或者将alpha淡入/淡出0,或者更改xy坐标以将其设置为屏幕上/屏幕上的动画等等。

In the example I've posted there is a UILabel on top of the container which of course could be anything (including a whole hierarchy of views, or another container view with another view controller embedded with in it, whatever you want). You can make it appear or disappear as need be throughout the rest of the program either by creating/destroying it as needed, or fading the alpha to/from 0, or changing the x.y co-ordinates to animate it onto/off of the screen etc.

这篇关于如何通过整个iOS应用程序保留滑出侧边栏菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆