iPhone SDK 中的视图控制器
我正在读一本名为《Beginning iPhone 3 Developement - Exploring the iPhone SDK》的书,作者是 Dave Mark 和 Jeff LaMarche。我已经了解了导航控制器和多视图应用程序,现在我想创建自己的小应用程序,一个非常简单的 Twitter 应用程序。我想要一个登录视图,如果登录成功,我希望向用户呈现一个带有选项卡栏的视图,其中每个选项卡都是更新、时间轴等。现在我只是去更新视图。
所以我想到了一个基于导航的应用程序。第一个视图(登录视图)位于堆栈的底部。当用户登录时,带有选项卡栏的视图被推送到堆栈上。然后用户可以在选项卡中执行他想要的任何操作。然后,他应该能够按下某种注销按钮,这会将选项卡栏视图从堆栈中弹出,并将用户带回登录视图。
现在我的问题(抱歉我的解释很长):这是要走的路吗?如果是这样,我该怎么做?我是否创建一个名为 LoginViewController 的视图控制器(它是 UINavigationController 的子类),还是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 UI 角度来看,更流畅的设计可能会使用 模式视图控制器。
模式视图控制器从屏幕底部弹出并显示其自己的视图。当这个视图被消除时,它会向下移动并消失。
在我看来,模态控制器是短暂身份验证屏幕的好地方 - 您只需将其置于视图中,用户输入他或她的信息,然后视图就会消失。
返回父视图控制器时,它会检查身份验证凭据,并在通过身份验证(或未通过身份验证)的情况下修改其视图。
模态视图控制器的另一个优点是它位于自己的导航堆栈上。所以你不需要推送一个控制器,弹出然后推送一个不同的视图控制器。它使代码和界面更加干净(同样,在我看来)。
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).