I need some help with trying to fix a problem when I run my app, either on a Device or in the iOS simulator it show a black screen but if I press the home button and then tap on app it shows all the content. Does anyone know what is actually happening?
我需要一些帮助,当我运行我的应用程序时尝试解决问题,无论是在设备上还是在iOS模拟器中它显示黑屏但是如果我按下主页按钮然后点击应用程序它会显示所有内容。有谁知道实际发生了什么?
Picture Of Simulator via Black Screen
模拟器的图片通过黑屏幕
import UIKit import Firebase import UserNotifications import FirebaseInstanceID import FirebaseMessaging
导入UIKit导入Firebase导入UserNotifications导入FirebaseInstanceID导入FirebaseMessaging
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDelegate, FIRMessagingDelegate{
@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
0
I think your rootviewcontoller view are two link views so remove all and other textfields and UIlabel remove. then run the application.
我认为你的rootviewcontoller视图是两个链接视图,所以删除所有和其他文本字段和UIlabel删除。然后运行应用程序。
//remove Newview in this picture
And I think the second solution is set rootviewcontoler programmatically.
我认为第二个解决方案是以编程方式设置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
1
Without seeing your code I have 2 solutions which are of course very broad:
没有看到你的代码我有2个解决方案,当然非常广泛:
- I guess your project doesn't have quite a lot of stuff. The best would be just redo it from scratch. Pretty sure you made some small mistake that you can't really find out and we can't too without seeing your code.
- 我猜你的项目没有很多东西。最好的只是从头开始重做。很确定你犯了一个小错误,你无法真正发现,我们也不能没有看到你的代码。
- Recall what you did so that it became like this (showing black screen) and revert your code and see what really made this black screen.
- 回想一下你做了什么,以便它变成这样(显示黑屏)并恢复你的代码,看看是什么真正使这个黑屏。
#1
0
I think your rootviewcontoller view are two link views so remove all and other textfields and UIlabel remove. then run the application.
我认为你的rootviewcontoller视图是两个链接视图,所以删除所有和其他文本字段和UIlabel删除。然后运行应用程序。
//remove Newview in this picture
And I think the second solution is set rootviewcontoler programmatically.
我认为第二个解决方案是以编程方式设置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
1
Without seeing your code I have 2 solutions which are of course very broad:
没有看到你的代码我有2个解决方案,当然非常广泛:
- I guess your project doesn't have quite a lot of stuff. The best would be just redo it from scratch. Pretty sure you made some small mistake that you can't really find out and we can't too without seeing your code.
- 我猜你的项目没有很多东西。最好的只是从头开始重做。很确定你犯了一个小错误,你无法真正发现,我们也不能没有看到你的代码。
- Recall what you did so that it became like this (showing black screen) and revert your code and see what really made this black screen.
- 回想一下你做了什么,以便它变成这样(显示黑屏)并恢复你的代码,看看是什么真正使这个黑屏。