Comments (4)
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.
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.
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.
Awesome :) Feel free to reach out anytime, we are here to help.
from samples.
Related Issues (20)
- How to use NavigationDrawer whit native UITabbarController? HOT 2
- How to open ViewControler from left or right drawer? HOT 5
- In CheckButton Unable to change the background color HOT 11
- Set base configuration of Checkbox to Tint = clear. HOT 1
- Type 'MotionTransitionAnimationType' has no member 'fadeSlide' HOT 1
- NavigationController has no shadow or elevation HOT 3
- Using NavigationController in storyboard HOT 1
- Error Launching Sample CollectionView HOT 3
- ToolbarController Sample not works HOT 2
- bug HOT 1
- Coming up with a basic design for a new Sample application
- Card \ PresenterCard sample does not show card in ios 13.1 HOT 3
- Value of type '(TabBar, TabItem) -> ()' has no member 'buttons' HOT 1
- ImageCard sample gives me a complete white screen
- Cannot Build with Xcode 11
- At the TableView, does not work padding.
- NavigationDrawer needs update?
- tabBarStyle = .scrollable alignment to right
- demo error
- Right To Left (for arabic country) view not supported.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from samples.