SWRevealViewController - RightViewController [英] SWRevealViewController - RightViewController

查看:187
本文介绍了SWRevealViewController - RightViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SWRevealViewController 在我的应用程序中实现两个侧面导航视图。我按照故事板方法成功实现了后视图和前视图。我尝试通过故事板设置正确的视图,就像后视图一样,但是无法做到。

I'm using SWRevealViewController for implementing two side navigation views in my application. I followed the story board method and successfully implemented the rear view and front view. I tried setting right view exactly like the rear view via storyboard, but couldn't do it.

我已将显示视图控制器segue设置为sw_right但看起来它不被识别 - (void)prepareForSegue :( SWRevealViewControllerSegue *)segue发送者:(id)发件人为sw_rear和sw_front调用两次

I have set the reveal view controller segue to "sw_right" but it looks like it is not being recognized by - (void)prepareForSegue:(SWRevealViewControllerSegue *)segue sender:(id)sender which is called twice for "sw_rear" and "sw_front"

我缺少什么?

What Am I missing?

- (void)prepareForSegue:(SWRevealViewControllerSegue *)segue sender:(id)sender
{
// $ using a custom segue we can get access to the storyboard-loaded rear/front view controllers
// the trick is to define segues of type SWRevealViewControllerSegue on the storyboard
// connecting the SWRevealViewController to the desired front/rear controllers,
// and setting the identifiers to "sw_rear" and "sw_front"

// $ these segues are invoked manually in the loadView method if a storyboard
// was used to instantiate the SWRevealViewController

// $ none of this would be necessary if Apple exposed "relationship" segues for container view controllers.

NSString *identifier = segue.identifier;
if ( [segue isKindOfClass:[SWRevealViewControllerSegue class]] && sender == nil )
{
    if ( [identifier isEqualToString:SWSegueRearIdentifier] )
    {
        segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
        {
            [self _setRearViewController:dvc animated:NO];
        };
    }
    else if ( [identifier isEqualToString:SWSegueFrontIdentifier] )
    {
        segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
        {
            [self _setFrontViewController:dvc animated:NO];

        };
    }
    //This is never executed even after setting the identifier
    else if ( [identifier isEqualToString:SWSegueRightIdentifier] ) 
    {
        segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
        {
            [self _setRightViewController:dvc animated:NO];
        };
    }
  }
}


推荐答案

我弄清楚问题是什么。在 loadStoryboardControllers 方法 [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil]; 已注释掉。如果我们实现了右视图控制器,则必须取消注释。

I figured out what the problem was. In loadStoryboardControllers method [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil]; was commented out. If we implement right view controller this has to be uncommented.

这篇关于SWRevealViewController - RightViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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