GithubHelp home page GithubHelp logo

Help with MenuController about samples HOT 4 CLOSED

cosmicmind avatar cosmicmind commented on May 11, 2024
Help with MenuController

from samples.

Comments (4)

daniel-jonathan avatar daniel-jonathan commented on May 11, 2024

Hey, I am happy that you are enjoying Material :) Thank you.

Yes, I can help. A little explanation of how to think of the navigation controllers in general (ToolbarController, MenuController, NavigationDrawerController, etc...) should help you.

The main idea is to provide flexibility in architecting your application. The first concept to understand is the layering system for navigation controls. You can layer the order in which you stack the navigation controllers, so that you can control your application's flow more easily. With the layering system, accessing the parent navigation controls is done through the optional helper accessor properties, such as: menuController?..., navigationDrawerController?..., etc...

So now that we have a layering system, we can decide to populate the navigation controllers, MenuController in your case, in different subview controllers. You have the choice of adding the MenuController at a high level, application wide, and then only revealing it and adding buttons from a view controller that appears within the hierarchy, for example SearchMenuItemsViewController.

Things to consider, that you cannot access the helper optional accessory properties for navigation controllers in the viewDidLoad method when you create the object and then add it as the rootViewController, like so:

searchMenuVC = SearchMenuViewController(rootViewController: SearchMenuItemsViewController())

The reason being is that the relationship, parent-child, is not yet established resulting in a nil value when using the helper accessory properties. So you need to access it in the viewWillAppear, or viewDidAppear method.

Setting the delegate can always change when you are introducing new view controllers, allowing you to reuse the same application wide navigation controller, which would require some planning to ensure you don't try and double bind a delegation object, much easier to do than it may sound.

Lack in response to clicking buttons is when you have set the handlers in a view controller that is then removed from the view hierarchy, so the handlers are no longer available. In this case, you would probably want to place the handlers in an object, or view controller that is always alive, such as a subclass of the navigation controller type itself, like AppMenuController.

Also please update to Material 2.3.12 as I pushed updates specifically for the MenuController and animations in iOS 8, 9, and 10.

Any questions so far?

from samples.

codemodouk avatar codemodouk commented on May 11, 2024

Hi Daniel,

Thanks for the quick and detailed response.

I think I understand from your explanation that the menuController property is available across sub view controllers to be used as required by those sub VCs.

What I don't understand, is where you would create it in a Storyboard based app. Sorry if I didn't make this clear in my initial post. My Storyboard setup uses a uitabbarcontroller as the initial view controller. One of the controllers on the tab bar controller needs to access and use the menuController property.

In the the sample app the MenuController sub class is instantiated in the app delegate, and made the rootViewController for the window. In my case, the rootViewController for the window is defined in the storyboard. So where do I instantiate my MenuController subclass?

I feel I'm missing something very obvious, so, I apologise if this sounds a bit basic. If I can assist further to help clarify my situation more please let me know.

Thanks again
Alex

from samples.

codemodouk avatar codemodouk commented on May 11, 2024

Hi Daniel,

A nights sleep makes everything much clearer! I've got my head around this now, and I'm able to move on. Please feel free to close the issue.

Thank you for your support.

Regards
Alex

from samples.

daniel-jonathan avatar daniel-jonathan commented on May 11, 2024

Awesome :) Feel free to reach out anytime, we are here to help.

from samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.