开发者

view controllers in the iPhone SDK

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 multi开发者_如何学编程view 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?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜