ios - 为什么在设备或模拟器中运行我的应用程序时屏幕是黑色的

标签 ios swift xcode swift3 xcode8

当我运行我的应用程序时,我需要一些帮助来尝试解决问题,无论是在设备上还是在 iOS 模拟器中,它都会显示黑屏,但如果我按下主页按钮,然后点击应用程序,它会显示所有内容.有谁知道实际发生了什么?

Picture Of Simulator via Black Screen

导入 UIKit 导入 Firebase 导入用户通知 导入 FirebaseInstanceID 导入 FirebaseMessaging

@UIApplicationMain AppDelegate 类:UIResponder、UIApplicationDelegate、UNUserNotificationCenterDelegate、FIRMessagingDelegate{

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FIRApp.configure()
    application.statusBarStyle = .lightContent

    if #available(iOS 10.0, *) {
        // For iOS 10 display notification (sent via APNS)
        UNUserNotificationCenter.current().delegate = self
        let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
        UNUserNotificationCenter.current().requestAuthorization(
            options: authOptions,
            completionHandler: {_, _ in })
        // For iOS 10 data message (sent via FCM
        FIRMessaging.messaging().remoteMessageDelegate = self
    } else {
        let settings: UIUserNotificationSettings =
            UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
    }

    application.registerForRemoteNotifications()
     return true

}

func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
    print(remoteMessage.appData)
}

func applicationWillResignActive(_ application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

最佳答案

在没有看到您的代码的情况下,我有 2 个解决方案,它们当然非常广泛:

  1. 我猜你的项目没有太多东西。最好的办法就是从头开始重做。很确定你犯了一些你无法真正发现的小错误,我们也不能在没有看到你的代码的情况下发现。
  2. 回想一下你做了什么让它变成这样(显示黑屏)并还原你的代码,看看究竟是什么导致了这个黑屏。

关于ios - 为什么在设备或模拟器中运行我的应用程序时屏幕是黑色的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45359585/

相关文章:

ios - 尽管将 info.plist 更改为 NSAppTransport Security 为 NO Xcode 7.2 iOS 9.2,但仍出现 App Transport Security 错误

ios - Objective - C 核心数据建模

ios - 执行应用内购买时发生 "Your request produced an error [new nullrespone]"

ios - 安装 Xcode 5 后无法再拖放到 Storyboard 上

iphone - iOS 上的 native RFID 检测

ios - 横向拖放图像不起作用

ios - 如何检查 textFieldView 是否为空或没有空格?

iOS/swift : Determine vertical position of last populated row of tableview

ios - RxSwift 在关闭时正确处理订阅

php - "Delivered Message to APNS"但在使用 ios13 (PHP) 的生产环境中未显示通知