呈现 UINavigationController 多个深度视图,作为初始视图

发布于 2024-10-11 06:34:49 字数 303 浏览 2 评论 0原文

在我的应用程序中,我希望有一个初始屏幕,允许用户注册(基于网络的)服务。完成此操作后,他们将自动登录。这些屏幕将显示为 UINavigationController 中的视图,类似于:

1.Opening view > 2.Sign up view > 3.Logging in view > 4.Logged in view

注册后,下次启动应用程序时,应用程序应直接转到视图 3(记录在)。我将如何将这一观点呈现为最初的观点? (另一个问题 - 如果用户决定注销,我如何从视图 4 返回到视图 1?)

In my app I would like to have an initial screen which allows the user to sign up for a (web-based) service. Once they have done this, they will automatically log in. These screens will be presented as views within a UINavigationController, something like:

1.Opening view > 2.Sign up view > 3.Logging in view > 4.Logged in view

Once they have signed up, the next time the app is launched, the app should go straight to view 3 (logging in). How would I present this view as the initial one?
(an additional question - how would I return to view 1 from view 4 if the user decides to log out?)

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

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

发布评论

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

评论(1

你是我的挚爱i 2024-10-18 06:34:49

字面上的答案(“如何更改初始视图?”)将是更改您的应用程序委托:

-(BOOL)application:(UIApplication *)application
       didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    if ( newuser )
    {
        [window addSubview:viewController1.view];
    } else {
        [window addSubview:viewController2.view];
    }
}

在您的 xib 文件中使用两个 UINavigationController。但这可能感觉有点不正统,并会引发其他问题。否则,通过让视图控制器 1 和 2 立即推送下一个控制器而不使用动画,立即推送整个视图控制器堆栈。

然后用户将只看到“登录视图”。如果您决定让用户从堆栈中弹出视图 4 和 3,则视图控制器 2 将出现。

您可以通过调用类似 [self.navigationController popToRootViewControllerAnimated:NO] 来弹出整个堆栈

The literal answer (to "how to change initial view?") would be to alter you app delegate:

-(BOOL)application:(UIApplication *)application
       didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    if ( newuser )
    {
        [window addSubview:viewController1.view];
    } else {
        [window addSubview:viewController2.view];
    }
}

with two UINavigationControllers in your xib file. But this may feel a little unorthodox and give rise to other issues. Otherwise, instantly push the whole viewcontroller stack on it, by having your viewcontrollers 1 and 2 immediately push the next controllers without animation.

The user will then just see the "Logging in view". If you decide to let the user pop views 4 and 3 off the stack, viewcontroller 2 will appear.

You can pop the entire stack by calling something like [self.navigationController popToRootViewControllerAnimated:NO]

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