I am developing an app on Visual Studio for Mac with Xcode. I have a Window Controller with Sidebar that gives you a split view controller that is split into a sidebar controller and a view controller.
Right now it looks like this:
I want to be able to toggle the left sidebar (as in collapse or show) when I click on the sidebar icon in the toolbar. I added the icons in the toolbar as Custom Toolbar Items by just dragging and dropping a textured round button and putting an icon in it.
Does anyone have an idea as to how to do this? is there a function already that I need to call? would greatly appreciate it.
So far, I found online some resources like the following: https://developer.apple.com/forums/thread/705335
However they are all in Swift and I could not find any equivalents for C#.
CodePudding user response:
from the docs
Optionally, you can show and hide the Master View Controller using the PreferredDisplayMode property of the Split View Controller
CodePudding user response:
I found a very simple way to do it if you are using storyboards on Xcode.
1.) Select the First Responder in the Interface Hierarchy
2.) Scroll down in the Connection Inspector, and you will see the definition of the toggleSidebar:
action.
3.) Click on the icon on the right of the action and drag it to the Sidebar button on your Document outline (under toolbar).
you now connected the built-in toggleSidebar action to the sidebar toolbar item.