Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use MainController in iOS #36

Open
onmyway133 opened this issue May 12, 2017 · 0 comments
Open

How to use MainController in iOS #36

onmyway133 opened this issue May 12, 2017 · 0 comments

Comments

@onmyway133
Copy link
Owner

onmyway133 commented May 12, 2017

Usually in an app, we have these flows: onboarding, login, main. And we usually set OnboardingController, LoginController and MainController as the root view controller respectively depending on the state.

I find it useful to have the MainController as the container for main flow. It can be a tab controller, swipe menu controller or contains just 1 child view controller. The screens are provided by child view controllers, but the MainController does the following jobs

  • Status bar style

We usually need to call preferredStatusBarStyle on the parent controller. See https://stackoverflow.com/questions/19022210/preferredstatusbarstyle-isnt-called

  • App did become active

Usually when app is brought to foreground, we need to fetch logged in user profile to see if there's changes. We do this by listening to app did become active in MainController.

  • Mock to open

This can be anti pattern. But in UI Tests, for laziness, we can just use some launch arguments and check to present some specific screens to test, because MainController is the root for main flow.

  • Logout

Because things originate from MainController, things can terminate in MainController. We can handle logout, clear states, and tell MainController to tell AppDelegate to switch to another root controller

@onmyway133 onmyway133 changed the title The MainController How to use MainController in iOS May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant