当我运行我的应用程序时尝试解决问题需要一些帮助,无论是在设备上还是在iOS模拟器中它显示黑屏但是如果我按下主页按钮然后点击应用程序它会显示所有内容。有谁知道实际发生了什么?
Picture Of Simulator via Black Screen
导入UIKit 导入Firebase 导入UserNotifications 导入FirebaseInstanceID 导入FirebaseMessaging
@UIApplicationMain class 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:.
}
}
答案 0 :(得分:1)
如果没有看到您的代码,我有2个解决方案当然非常广泛:
答案 1 :(得分:0)
我认为你的rootviewcontoller视图是两个链接视图,所以删除所有和其他文本字段和UIlabel删除。然后运行应用程序。
//remove Newview in this picture
我认为第二个解决方案是设置rootviewcontoler 编程。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if let rvc = self.window?.rootViewController {
self.window!.rootViewController = rvc.storyboard!.instantiateViewControllerWithIdentifier("rootviewcontoller")
}
return true
}
答案 2 :(得分:0)
我遇到了同样的问题。阅读完控制台日志后,我意识到即使将文件复制并放入项目目录中,也未将GoogleService-Info.plist
添加到Xcode项目中。要解决此问题,请手动将GoogleService-Info.plist
添加到Xcode中。单击File
-> Add File to project
并选择文件。再次运行该项目,问题应该得到解决。编码愉快!