I have a navigation app that has many screens the user navigates to. A handful of views manages these screens dynamically. What I want to try to do is add a button that will always show up on every screen the user views. I need to do this so that the user is always able to preform the action associated with the button regardless of where they are in the app.
Is it possible to achieve this by adding this button only once and having it passed between views like my navigation bar is? Or do I just have to man up and add this button and its functionality to every single view file I have?
Thanks
I would say it probably depends on what the button does. If the button is generic to all views, meaning it affects all views the same exact way so no customization for a given view is needed, then a way to do this would be to include the function in the App Delegate or as a subclass to your Navigation controller.
You can then use the
rightBarButtonItemto always show the same button and just access that method. You would just have to add code for therightBarButtonItemin eachviewDidLoad(but they’d all be the same).I did something similar to this with an “Upgrade” button on one project. Since all the button does is launch the AppStore to the paid version, it’s independent of all views and I can place it anywhere.