swift - 为什么在 xcode 中构建时应用程序变黑了?试图保持用户登录
问题描述
我试图保持用户登录,所以我写了这段代码:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
let window = UIWindow(windowScene: scene as! UIWindowScene)
// Assign window to SceneDelegate window property
self.window = window
if let loggedIn = UserDefaults.standard.bool(forKey: "IsUserLoggedIn") as? Bool{
if loggedIn{
//set your login viewcontroller as root viewcontroller
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = mainStoryBoard.instantiateViewController(withIdentifier: "MainViewController")
self.window?.rootViewController = initialViewController
}else{
//open the home screen
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = mainStoryBoard.instantiateViewController(withIdentifier: "TabBarController")
self.window?.rootViewController = initialViewController
}
self.window?.makeKeyAndVisible()
guard let _ = (scene as? UIWindowScene) else { return }
}
}
它工作正常,但是现在当我构建时,我只得到一个黑屏,并显示以下错误消息:
true
2020-10-20 20:51:14.189415-0400 SimpleProject[80132:3661837] 6.31.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60800000 started
2020-10-20 20:51:14.191734-0400 SimpleProject[80132:3661755] [Firebase/Crashlytics] Version 4.5.0
2020-10-20 20:51:14.189967-0400 SimpleProject[80132:3661837] 6.31.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-10-20 20:51:14.205520-0400 SimpleProject[80132:3661836] 6.31.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-10-20 20:51:14.249061-0400 SimpleProject[80132:3661864] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2020-10-20 20:51:14.291600-0400 SimpleProject[80132:3661755] [Presentation] Presenting view controller <SimpleProject.MainViewController: 0x7f91acb232f0> from detached view controller <SimpleProject.HomeViewController: 0x7f91ab712560> is discouraged.
2020-10-20 20:51:14.341389-0400 SimpleProject[80132:3661755] Unbalanced calls to begin/end appearance transitions for <SimpleProject.TabBarController: 0x7f91ae040a00>.
2020-10-20 20:51:14.343040-0400 SimpleProject[80132:3661834] 6.31.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-10-20 20:51:14.374641-0400 SimpleProject[80132:3661834] 6.31.0 - [Firebase/Crashlytics][I-CLS000000] Failed to download settings Error Domain=FIRCLSNetworkError Code=-5 "(null)" UserInfo={status_code=404, type=2, request_id=, content_type=text/html; charset=utf-8}
2020-10-20 20:51:14.386999-0400 SimpleProject[80132:3661833] 6.31.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-10-20 20:51:14.393543-0400 SimpleProject[80132:3661834] 6.31.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
解决方案
推荐阅读
- apache-spark - 如何在 Spark Streaming 中跟踪数据滞后 b/w EventHub 和 Blob
- react-native - React Native/Firebase App - 如果用户退出应用程序,希望倒计时功能停止
- c++ - 使用动态数组求和和平均
- java - 如何使用调色板库设置操作栏的颜色?
- android - Android Studio 中的自定义组件
- java - 损坏的管道 InputStream 到 Process (ProcessBuilder) 的 OutputStream
- c - 我们可以使用 netlink 传递的最大缓冲区大小和 PAGE_SIZE 对它的影响
- java - 如何从java中的firebase存储中获取照片的链接,而不是android
- ios - 如何在单元格单击时显示 UITableviewCell 的 editActionsForRowAtIndexPath 按钮
- express - Joi HapiJS 验证对象中键列表中的至少一个键为真