handsomecode / InteractiveSideMenu

iOS Interactive Side Menu written in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

showSideMenu() no response

Recouse opened this issue · comments

In SideMenuItemContent added this code:

func openMenu() {
    showSideMenu()
}

and:

menuButton.addTarget(self, action: #selector(openMenu), for: .touchUpInside)

But when I click the button there is no response.

Hi, @Recouse

Thanks for your question!

Please make sure that you already added your viewController that implements SideMenuItemContent protocol to an array of contentViewControllers within your container VC.

Here's an example.

Let us know if it doesn't help you.

Yes, I've added my viewController to an array of contentViewControllers. In that list my UINavigationController which connected with viewController. In array of contentViewControllers my UINavigationController's id.

@Recouse Unfortunately, We weren't able to reproduce this issue.
So, could you provide more detailed information about your case? It would be great to see some code examples.

Hi Firdavs,

UINavigationViewController should adopt SideMenuItemContent protocol directly, not any other connected controllers:

import UIKit
import InteractiveSideMenu

class NavigationViewController: UINavigationController, SideMenuItemContent {

}

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        title = "Test App"
    }

    @IBAction func openMenu(_ sender: Any) {
        if let navigationViewController = self.navigationController as? SideMenuItemContent {
            navigationViewController.showSideMenu()
        }
    }
}

I've updated the code of your ViewController file and now menu opens.

Hope, it'll help you.

@okonor Now it works. Thanks.