0

我是 iOS 开发的新手(但在其他平台上拥有超过 10 年的整体经验,所以应该会有所帮助)。现在我必须创建相对复杂的 iOS 应用程序并且做得非常快:)。

我使用情节提要基于“选项卡式应用程序”模板创建了应用程序。然后我添加了使用 JSON 与 Web 应用程序通信的登录视图。我通过将适当的箭头从默认选项卡栏控制器移动到我的“登录视图控制器”来使这个视图初始(用户首先看到)。

在登录视图中,我有文本字段和登录按钮。通过单击按钮应用程序验证用户名和密码,然后将他导航到默认选项卡栏控制器(由 Xcode 创建)。我用这段代码来做:

WPFirstViewController *fvc = [self.storyboard instantiateViewControllerWithIdentifier: @"TabBars"];
[fvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:fvc animated:YES completion:nil]; 

一切正常,但我很困惑,因为我没有在故事板上的视图之间使用图形线,而且我不确定我的方法是否正确。

那么,问题是我应该如何将用户从登录视图导航到标签栏控制器?就我而言,最好的方法是什么?而且,例如,我应该如何将用户从选项卡视图控制器页面页面之一(例如,通过单击“设置”按钮)导航到相应的视图,然后返回?也许有人可以分享一些好文章的链接。

对不起,很长的文字。预先感谢您的帮助!

4

3 回答 3

1

我建议你不要使用故事板。此外,如果您打算在您的应用程序上安装一个导航控制器,那么您肯定会使用在self.navigationViewController您的视图控制器上推送视图控制器的功能。它易于使用,非常简单!!

于 2013-04-07T22:06:27.267 回答
1

Modal view controllers are supposed to be used for cases where you need to get some critical information from the user (or present some to the user), without which you can't continue with the app. A log in controller would be a good choice for a modal view controller, but your main controller, your tab bar controller isn't. It would be better to present the login controller modally from the controller in the first tab of your tab bar controller. If you do this from viewDidAppear, and with no animation, it will be the first thing the user sees. When the user successfully logs in, just dismiss that controller, and you'll be ready to go in your first tab.

I'm not sure what you mean by your second question. The user navigates between the tabs by clicking on a tab -- you don't need to do anything in code for that.

于 2013-04-08T04:15:42.643 回答
0

Typically, login view controllers should be modally presented with: presentModalViewController:animated:

In regards to your UITabBarController, each tab can be a UINavigationController, which will enable you to maintain a stack of UIViewControllers.

All the remains is determining whether the view controller you want to present is modal, or part of said stack.

于 2013-04-08T00:35:44.480 回答