如何使我的应用程序始终从第二个视图开始?

发布于 2024-12-29 07:03:15 字数 473 浏览 0 评论 0原文

我有一个 Web 服务应用程序,它有一个登录视图。我想让我的应用程序的登录视图在第一次加载(安装)应用程序时出现,之后它必须始终以第二个视图开始。我怎样才能做到呢?在链接中有一些解决方案,但我认为这不是我正在寻找的。由于我的是一个网络服务,意味着第二个视图的内容(我想一直推送)是从服务器获取的(我使用 NSJSONSerialization 这项工作的类)

I have a Web Service application and it has alogin view. I want to make my application's login view come when the first time app is loaded(installed) and after that it must allways start with a second view. How can i make it? In this link there are some solutions but i think this isn't what i'm looking for. Since mine is a web servise, mean the content of the second view(which i want to be pushed allways) is fetched from a server(i use NSJSONSerialization class for this work)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水水月牙 2025-01-05 07:03:15

我会将登录视图作为模态视图,仅在需要时才显示。

编辑:
这是非常简短的:(我假设您正在使用 ARC。)

在 AppDelegate:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: mySecondViewController];

if (![self isUserLoggedIn]) {
    MyLogInViewController *logInViewController = [[MyLogInViewController alloc] init];
    [self presentModalViewController: MyLogInViewController animated: YES];
}
[[self window] setRootViewController: [self navigationController]];

和 logInViewController 中:

- (void)logInSuccessful {
    [self dismissModalViewControllerAnimated: YES];
}

I would do the login view as a modal view which is only presented when needed.

Edit:
This is VERY brief: (I assume that you are using ARC.)

In AppDelegate:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: mySecondViewController];

if (![self isUserLoggedIn]) {
    MyLogInViewController *logInViewController = [[MyLogInViewController alloc] init];
    [self presentModalViewController: MyLogInViewController animated: YES];
}
[[self window] setRootViewController: [self navigationController]];

and in logInViewController:

- (void)logInSuccessful {
    [self dismissModalViewControllerAnimated: YES];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文