Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate to the left viewcontroller from the main viewcontroller #35

Closed
gangelo opened this issue Oct 28, 2017 · 5 comments
Closed

Delegate to the left viewcontroller from the main viewcontroller #35

gangelo opened this issue Oct 28, 2017 · 5 comments

Comments

@gangelo
Copy link

gangelo commented Oct 28, 2017

I am trying to find a way to delegate to the left view controller (menu) from the main view controller. Basically, my left menu has a menu option called "Refresh" in which, when clicked, I was hoping to dismiss the menu and call a "refresh" member within the main view controller that refreshes the data in the table view controller on that screen. I am sure there are other ways to do this that don't have to involve all this, but it seems the right place to put the option for my app. Is this possible?

@iDevelopper
Copy link
Owner

Of course it is possible. No delegate needed to do that, simply call the method refresh from left view controller. Do you use Swift or ObjC?

@gangelo
Copy link
Author

gangelo commented Oct 28, 2017

Swift 3

@iDevelopper
Copy link
Owner

Assuming your main view controller is embedded in a navigation controller:

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        //...
        //...
        let nc = self.revealViewController()?.mainViewController as? UINavigationController
        let controller = nc?.topViewController as? YourMainViewController
        controller?.refresh()
        self.revealViewController()?.hideLeftView(animated: true)
        //...
    }

@gangelo
Copy link
Author

gangelo commented Oct 28, 2017

I will give it a try tonight thank you very much. I’ll let you know how it goes.

@gangelo
Copy link
Author

gangelo commented Oct 29, 2017

Worked great ty!

@gangelo gangelo closed this as completed Oct 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants