0

Up until now, I was using the SWRevealViewController library, available at GitHub. This worked well for me, as you can see here:

enter image description here

How can I achieve parallax effect in this sidebar menu?

Furthermore, I also tried some other ways more specific to my target, like https://github.com/SSA111/SSASideMenu.

And I got this result:

enter image description here

But just after any type of GRE Test is selected, the front view with that specific category selected is shown.

enter image description here

But now on clicking menu bar button at the top of GRE Main, the sidebar menu does not appear, and instead gives this error:

fatal error: unexpectedly found nil while unwrapping an Optional value

This error is targeted in library file SSASideMenu, where it says that parent ViewController is found nil for this front view controller. Because SSASideMenu check the sender by its parent.

If parent matches SSASideView, then it loads sidebar menu.

Here is my code:

extension UIViewController {

    var sideMenuViewController: SSASideMenu? {
        get {
            print(" >>>>>>>>>> ????????? ///////////// Here we are")
            return getSideViewController(self)
        }
    }

    private func getSideViewController(viewController: UIViewController) -> SSASideMenu? {

        var parent = viewController.parentViewController

        if parent == viewController.parentViewController {
            if parent is SSASideMenu
            {
                print("2nd Step")
                return parent as? SSASideMenu
            }
            else
            {
                parent = viewController.parentViewController
                print("1st Step")
                return getSideViewController(parent!)
            }
        }

        return nil
    }

    @IBAction func presentLeftMenuViewController() {
        sideMenuViewController?._presentLeftMenuViewController()
    }

    func showPresent()
    {
        print("Hello")
        sideMenuViewController?._presentLeftMenuViewController()
    }

    @IBAction func presentRightMenuViewController() {
        sideMenuViewController?._presentRightMenuViewController()
    }

}

Finally, in the ViewController it is simply used as

button.addTarget(self, action: #selector(SSASideMenu.showPresent), forControlEvents: UIControlEvents.TouchUpInside)
Brian
  • 14,610
  • 7
  • 35
  • 43
Asim Khan
  • 508
  • 1
  • 7
  • 21

0 Answers0