views:

31

answers:

1

Hello. I will begin by saying that I'm 15 years old and from Sweden, so please excuse my English.

I'm reading a book called Beginning iPhone 3 Developement - Exploring the iPhone SDK, by Dave Mark and Jeff LaMarche. I've read about navigation controllers and multiview applications, and now I want to create my own little app, a very simple Twitter app. I want a login view, and if the login is successful I want the user to be presented a view with a tab bar, where each tab is Update, Timeline and such. Right now I'm just going for the update view.

So I thought about a navigation-based app. The first view, the login view, is on the bottom of the stack. When the user logs in, the view with the tab bar is pushed on to the stack. Then the user does whatever (s)he wants there, in the tabs. (S)he should then be able to press some kind of logout button, which pops the tab bar view off the stack, and takes the user back to the login view.

Now to my question (sorry for my long explanation): is this the way to go? If so, how do I do it? Do I create a view controller called LoginViewController, which is subclassing UINavigationController, or what?

+1  A: 

From a UI perspective, a more fluid design might use a modal view controller.

A modal view controller pops up from the bottom of the screen and displays its own view. When this view is dismissed, it shuffles down and disappears.

In my opinion, a modal controller is a good place for a transient authentication screen — you just bring it in view, the user enters his or her info, and the view is dismissed.

On returning to the parent view controller, it checks the authentication credentials and modifies its view if authenticated (or not).

Another advantage of the modal view controller is that it is on its own navigation stack. So you don't need to push a controller, pop up and then push a different view controller. It makes for cleaner code and a cleaner interface (again, in my opinion).

Alex Reynolds
+1. Haha for a second i thought you wrote "model-view-controller".
Jacob Relkin
Thanks, I'll have a look at that.
Christian Persson
How will I be notified when the modal view controller is or will be dismissed? I'm new to Objective-C, so I don't quite understand the delegate thingy. In the link you provided, they seem to be declaring their own delegate/protocol, but is there no standard method like navigationControllerDidDismiss or something?
Christian Persson
View controllers have the delegates ‘-viewWillDisappear:‘ and ‘-viewDidDisappear:‘ that are called when the view will or has disappeared. You can override these and add your custom logic.
Alex Reynolds