【问题标题】:SWRevealViewController and 3D Touch quickActionsSWRevealViewController 和 3D Touch quickActions
【发布时间】:2016-01-16 12:18:34
【问题描述】:

我有一个应用程序在 swift 中实现侧边菜单。 (http://www.appcoda.com/sidebar-menu-swift/)

我实现了 3D 触摸快捷方式,快速操作,它几乎可以工作。

问题是我直接到达我的视图而没有实例化revealViewController(),代码如下:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let navVC = storyboard.instantiateViewControllerWithIdentifier("newsViewController") as! UINavigationController
self.window?.rootViewController?.presentViewController(navVC, animated: true, completion: nil)

我不知道如何/在哪里实例化revealViewController()。

我有:

self.revealViewController() == nil 

现在发生的情况是菜单不想打开。

感谢您的帮助:-)

【问题讨论】:

    标签: swrevealviewcontroller quickaction 3dtouch


    【解决方案1】:

    为了让你的显示 ViewControlled 你必须在故事板中将它作为 InitialViewController,不需要在 Appdelgate 中编写任何代码。

    您可以在git hub storyboard example 中找到最佳示例 要么 设置如下屏幕截图

    【讨论】:

    • 问题是当我使用 3D Touch 快速操作时,应用程序直接进入我使用 quickActions 选择的视图中,因此应用程序既不通过 sw_rear 也不通过 sw_front。我该如何解决?
    【解决方案2】:

    您可以通过以下链接找到答案: How to push viewcontroller from appdelegate in storyboard

    我写的代码如下它对我有用。

        UIStoryboard *st = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        SWRevealViewController *mainRevealController = [[SWRevealViewController alloc] init];
        CaseCollectionViewController *descController = (CaseCollectionViewController*)[st instantiateViewControllerWithIdentifier: @"CaseCollection"];
        descController.selectedLevel = @"pll";
        descController.title = @"PLL";
    
        //UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:descController];
        UINavigationController *frontNavigationController = (UINavigationController*)[st instantiateViewControllerWithIdentifier: @"NavigationViewCtrl"];
        [frontNavigationController setViewControllers:@[descController]];
        SidebarTableViewController *rearViewController = (SidebarTableViewController*)[st instantiateViewControllerWithIdentifier: @"SideBarView"];
        mainRevealController.rearViewController = rearViewController;
        mainRevealController.frontViewController = frontNavigationController;
        self.window.rootViewController = mainRevealController;
    

    【讨论】:

      【解决方案3】:

      对于那些想要使用 Swift 的人:

      let storyboard = UIStoryboard(name: "Main", bundle: nil)
      let frontNavigationController = storyboard.instantiateViewControllerWithIdentifier("planningViewController")
      let rearNavifationController = storyboard.instantiateViewControllerWithIdentifier("menuViewController")
      let mainRevealController : SWRevealViewController = SWRevealViewController(rearViewController: rearNavifationController, frontViewController: frontNavigationController)
      self.window?.rootViewController? = mainRevealController
      

      【讨论】:

        【解决方案4】:

        用于深度链接的Objective-c代码。它将通过侧边菜单打开主页并将主页(前视图控制器)推送到通知视图控制器。

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UINavigationController *frontViewControllerNav = [storyboard instantiateViewControllerWithIdentifier:@"homeNav"];// navigation controller of home screen..
        UINavigationController *rearViewControllerNav = [storyboard instantiateViewControllerWithIdentifier:@"sideMenuNav"];//navigation controller of menu screen..
        
        SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearViewControllerNav frontViewController:frontViewControllerNav];
        revealController.delegate = self;
        UIViewController *notificationView=[storyboard instantiateViewControllerWithIdentifier:@"notificationVC"];
        [frontViewControllerNav pushViewController:notificationView animated:NO];
        revealController.bounceBackOnOverdraw=NO;
        //revealController.stableDragOnOverdraw=YES;
        self.window.rootViewController = revealController;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-08-31
          • 1970-01-01
          • 2017-02-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-07-17
          相关资源
          最近更新 更多