SWRevealViewController

SWRevealViewController

本文介绍了SWRevealViewController-手动切换到另一个视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用SWRevealViewController制作的侧边栏菜单.

I have a sidebar menu, made with SWRevealViewController.

侧边栏中的菜单元素之一是登录".它将打开登录视图(通过自定义SWRevealViewController segue).

One of menu elements in sidebar is "sign-in". It opens sign-in view (via custom SWRevealViewController segue).

我要在用户成功登录后以编程方式切换到另一个视图.我该怎么做?

I want to programmatically switch to another view after user successfully signs in. How do I do that?

更新,我的代码:

ViewController *vc = [[ViewController alloc] init]; // this is main front ViewController
SWRevealViewController *revealController = self.revealViewController;
[revealController setFrontViewController:vc animated:YES];

在此之后,我只是空白屏幕.我究竟做错了什么?我觉得这是错误的:

After this I get just empty screen. What am I doing wrong? I feel that this is wrong:

ViewController *vc = [[ViewController alloc] init];

那么访问已加载的视图控制器的正确方法是什么? (它在应用启动时由SWRevealViewController作为前端控制器加载)

so what is correct way to access already loaded view controller? (it loads at app start by SWRevealViewController as front controller)

推荐答案

使用- (void)setFrontViewController:(UIViewController *)frontViewController animated:(BOOL)animated;方法

SWRevealController具有其自己的属性,可以从任何UIViewController访问:

SWRevealController has it's own property you can access from any UIViewController:

SWRevealViewController *revealController = self.revealViewController;

您可以在GitHub存储库中查看示例项目: https://github.com/John-Lluch/SWRevealViewController

You can check example projects at it's GitHub repository:https://github.com/John-Lluch/SWRevealViewController

这篇关于SWRevealViewController-手动切换到另一个视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-24 12:14