0

I'm asking this in the context of the common scenario of having a modal "Log In" view, and then showing the main view of the app when the log in is successful and the view is dismissed (as it can be seen in Twitter, Evernote, and so on..), instead of showing again the "welcome" view that presented the login view. I don't find any example of how can I achieve this.

Thanks!

EDIT: What I want to achieve is clearly shown in Instagram app. If you're not logged in, you are shown a welcome view with the logo and a table with "Register" and "Sign In" cells. From there, you can navigate to the corresponding register/sign in view. If you sign in, the "Sign In" view is dismissed with animation and the app's main view is shown below.

I tried to make my main view the rootViewController of my app and then to present an UINavigationController with the welcome view if the user is not logged in, but this way the main view is always shown first. Surprisingly, I don't find any example of handling this scenario and I think this is a very common one (having a welcome view if login needed and app's main view being only shown if login is successful or it was already done). I'd really appreciate some help and/or any example code.

Thanks again

EDIT2: I moved this particular question to Managing view controllers in an app where sign up required

Community
  • 1
  • 1
AppsDev
  • 12,319
  • 23
  • 93
  • 186
  • So you only want the loginview to show at startup of the app? – Arbitur Jul 19 '13 at 19:28
  • @Arbitur I firstly show a welcome view with "Sign In" and "Sign Up" buttons. If "Sign In" tapped, I present modally the corresponding view. I want to directly show the main app view after dismissal, as existing apps do (something similar to Twitter app, for example). If user wants to log out, I'll show the welcome view again. – AppsDev Jul 19 '13 at 19:31
  • I would make your main app view present the welcome view as well as doing the presenting of the login view. That way the main view can have the control over which view should be showing. – Eric Jul 19 '13 at 19:34
  • so the login view is a UIView an not a UIViewController? – Arbitur Jul 19 '13 at 19:34
  • Stick the Welcome view in a navigation controller and present it as a modal view at the start of your app. If the user selects login, push the login view onto the navigation controller. If login successful, dismiss the navigation controller and the main view will be shown. If logout, present the navigation controller with login. – rocky Jul 19 '13 at 20:02
  • @Arbitur Sign-in view is a `UIViewController` as well – AppsDev Jul 20 '13 at 06:03
  • @Eric Should it be "correct" to present the whole navigation hierarchy I have? I mean, I have a "welcome" view and I can navigate either a sign-in view or a sign-up view from there. Actually, I'm showing the sign-up view by pushing it onto the navigation stack where the "welcome" view is as the root, but the sign-in view is presented by the "welcome" view. If I make the main view present the welcome view, then I'll have a presented view on top of another presented view when showing the sign-in. – AppsDev Jul 20 '13 at 06:09
  • @rocky I'm currently showing the sign-in view as presented since I made the impression that most known apps consider it a modal task and present their sign-in views. Maybe I'm wrongly relating modal tasks and presented views concepts. Would it be more correct to present modally the sign-in view, or to push it onto the navigation stack? – AppsDev Jul 20 '13 at 06:20
  • Your welcome, sign in, and sign up views should all be in one navigation controller that is presented as a modal view. So the navigation stack can look like this: Welcome->Sign in->Dismiss modal view on success, Welcome->Sign Up->Create Account->Dismiss modal on success. – rocky Jul 20 '13 at 07:57
  • @AppsDev I would have your home screen as the root of your nav. I would then on first load have the homescreen present a UINavigationController with the Welcome view as it's root. Then from the welcome view you can push on the sign in/ create account pages and dismiss the whole navigation stack when they are finished. You could set the home screen as the delegate or use NSNotifications to broadcast events that the user does and have the homeview handle each. That's just my preference – Eric Jul 22 '13 at 18:14
  • @rocky @Eric If I make my main view present a `UINavigationController` with the welcome view if the user is not logged in, this way the main view is shown and then you can see how the welcome view is presented in top of it. I don´t want the user to see the main view if she should have to log in first... how could I solve this? – AppsDev Jul 27 '13 at 10:28

0 Answers0