首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何自动启动SWRevealViewController视图

如何自动启动SWRevealViewController视图
EN

Stack Overflow用户
提问于 2015-08-19 08:33:08
回答 2查看 142关注 0票数 0

我想在我到达我的视图后,在我的SWRevealViewController视图上自动启动。

举个例子,我是在我的SWRevealViewController和我去另一个视图。如果我想回去,我想继续我以前的状态:后视镜中的SWRevealViewController。

当我尝试的时候,我做了这个:

代码语言:javascript
复制
if (myPreviousVC == "editProfile")
{
     UIApplication.sharedApplication().sendAction(menuButton.action, to: menuButton.target, from: self, forEvent: nil)
}

这段代码只是推动启动我的menuButton的SWRevealViewController。

但我不喜欢这种方式,我想知道是否有一种方法,只是启动我的SWRevealViewController时,我已经到达正面的看法。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-20 12:32:01

我找到了答案。

它是:

代码语言:javascript
复制
if (myVariable == "stuff")
    {
        self.revealViewController().revealToggleAnimated(true)
        self.revealViewController().setFrontViewController(self, animated: true)
    }

有人能把这个答案写在“接受”里吗?

票数 0
EN

Stack Overflow用户

发布于 2015-08-19 10:01:38

你必须在你的故事板中使用sw_frontsw_rear。要做到这一点:

  1. 在故事板中添加一个UIViewController作为SWRevealViewController。
  2. 将自定义segue作为sw_rearSWRevealViewControllerSetSegue添加到菜单控制器中
  3. 将您的第一个ViewController链接为sw_front,同时也链接为SWRevealViewControllerSetSegue

有了这个,它将适用于,这是第一个视图

如果希望所有视图的菜单都为SWRevealViewController,则必须使用UINavigationControllers (如果需要的话在故事板中),然后将菜单控制器中的segue作为SWRevealViewControllerPushSegue链接到相应的UINavigationController

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32090376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档