A
A
alnite2022-02-21 14:07:59
Objective-C
alnite, 2022-02-21 14:07:59

Is there a best practice for switching between view controllers within a content view controller?

The application uses a content view controller (a subclass of UIViewController) with several view controllers inside. The entire interface is written entirely in code.
The first of the controllers is the main menu, from which you can switch to other controllers. Approximate scheme:

rootContainerViewController
         |                             |                     |                                                        
mainMenuViewController     optionsViewController    helpViewController  
          |- buttonToOption         |                        |                          
          |- buttonToHelp           backButton          backButton


Each button has a unique tag. The buttons are assigned target:
...Button addTarget: nil action: (buttonPressed)... The
touch on the button rises along the Responder chain to the rootContainerViewController, where it is processed in the buttonPressed method, going through all the tags that came from the button in the switch case block, and only then changing the required child view controllers.

"Is this generally normal"? Or are there some "more correct" methods of switching between controllers?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question