如果您已经获得授权,如何跳过登录场景并直接从下一个开始? [英] How to skip the login scene and start straight from the next if you are already authorized?

查看:106
本文介绍了如果您已经获得授权,如何跳过登录场景并直接从下一个开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查用户是否已经登录的最佳位置是什么,以及如何跳过登录viewController来实现向第一个应用场景的过渡?

What is the best place to check if the user is already logged-in and how to realize the transition to the first app scene skipping the login viewController?

推荐答案

我在AppDelegate中执行此操作.在我的主故事板上,我的初始视图控制器假定我的用户已登录.因此,在AppDelegate中,我执行以下操作来决定是否需要显示登录屏幕:

I do this in my AppDelegate. In my main storyboard, my initial view controller assumes that my user is logged in. Thus, in my AppDelegate I do the following to decide whether I need to show the login screen:

// Show login view if not currently logged in
if (!currentUser){

    let sb = UIStoryboard(name: MainStoryboardId, bundle: Bundle.main)
    let vc = sb.instantiateViewController(withIdentifier: loginViewControllerId)

    vc.modalTransitionStyle = .crossDissolve
    window.rootViewController = vc
    window.makeKeyAndVisible()
}

PS,只是从Objective-C转换的代码...未经测试.

PS, just converted code from Objective-C... it's untested.

这篇关于如果您已经获得授权,如何跳过登录场景并直接从下一个开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆