AKSwiftSlideMenu adding more view controllers

126 views Asked by At

I found the AKSwiftSlideMenu code to create a slide menu. The example works great.

I figured out how to add more item in the side menu, but when I click on the new items it will take me to my new viewcontroller but I don't have the '3 LINED MENU ICON' on the top.

SEE LINK TO VC3 BELOW case 0: print("Home\n", terminator: "")

        self.openViewControllerBasedOnIdentifier("Home")

        break
    case 1:
        print("Play\n", terminator: "")

        self.openViewControllerBasedOnIdentifier("PlayVC")

        break
    case 2:
        print("x\n", terminator: "")

        self.openViewControllerBasedOnIdentifier("VC3")

        break
    default:
        print("default\n", terminator: "")
    }
}

What are the steps to add a new VC3, I know how to add a new vc to the main storyboard, but can't seem to get the new vc to have the navigation bar and the '3 line menu' at the top of my new VC.

thanks

1

There are 1 answers

1
Joe On

Try this code:

Note: Below code has to go inside your BaseViewController.Make sure you set segue identifier and destinatinViewController on all viewController.

    func slideMenuItemSelectedAtIndex(index: Int32) {
    let topViewController : UIViewController = self.navigationController!.topViewController!

    switch(index){
    case 0:
        print("VC1\n", terminator: "")
        self.performSegueWithIdentifier("segueVC1", sender: nil)

        func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        self.performSegueWithIdentifier("segueVC1", sender: nil)
        segue.destinationViewController as! viewControllerOne
        }
        break

    case 1:
        print("VC2", terminator: "")
        self.performSegueWithIdentifier("segueVC2", sender: nil)

        func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        self.performSegueWithIdentifier("segueVC2", sender: nil)
        segue.destinationViewController as! viewControllerTwo    
        }
        break

    case 2:
        print("VC3", terminator: "")
        self.performSegueWithIdentifier("segueVC3", sender: nil)

        func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        self.performSegueWithIdentifier("segueVC3", sender: nil)
        segue.destinationViewController as! viewControllerThree      
        }
        break

    case 3:
        print("VC4", terminator: "")   
        self.performSegueWithIdentifier("segueVC4", sender: nil)

        func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        self.performSegueWithIdentifier("segueVC4", sender: nil)
        segue.destinationViewController as! viewControllerFour   
        }
        break

       default:
        print("default\n", terminator: "")
    }

Note : If you not using segue to connect VC's then you need a different approach.let me know.

Update:

Step1: Create a swift class for your newVC.

Step2: Drag newVC to your storyBoard and setup a custom class name.(newVc class name and VC custom class name should be match)

Step3: Connect AKSwiftSlideMenuVC to newVC and give name to your segueIdentifier.

Step 4: Goto BaseViewController update your case segueIdentifier and destVC...