如果您已获得授权,如何跳过登录场景并直接从下一个开始?
检查用户是否已登录以及如何实现跳过登录viewController的第一个应用场景转换的最佳位置是什么?
我在AppDelegate中这样做。 在我的主要故事板中,我的初始视图控制器假定我的用户已登录。因此,在我的AppDelegate中,我执行以下操作来确定是否需要显示登录屏幕:
// 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转换代码……它未经测试。
你可以尝试这样的事情:
- 在你的FirstViewController中,你检查用户是否已登录。如果是这样,你按下MainViewController,如果没有你按下LoginViewController,登录后你推送MainViewController。
您可以为FirstViewController构建一个克隆Splash接口的接口,因此用户在登录前不会注意到您有另一个viewcontroller。
喜欢这个: