如何在应用程序启动时根据是否启用推送通知来显示2个视图控制器之间的差异?我有以下代码,但是在启动小故事板后屏幕变黑了一段时间,而且速度太慢。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
let current = UNUserNotificationCenter.current();
current.getNotificationSettings(completionHandler:
{
(settings) in
if settings.authorizationStatus == .notDetermined
{
// self.window = UIWindow(frame: UIScreen.main.bounds);
self.window = UIWindow(frame: UIScreen.main.bounds)
let aViewController = AViewController();
self.window?.rootViewController = aViewController;
self.window?.makeKeyAndVisible();
}
else
{
// self.window = UIWindow(frame: UIScreen.main.bounds);
self.window = UIWindow(frame: UIScreen.main.bounds)
let bViewController = BViewController();
self.window?.rootViewController = bViewController;
self.window?.makeKeyAndVisible();
}
});
// Override point for customization after application launch.
return true
}
我可以将此代码放在其他地方吗?等待时可以扩展启动屏幕吗?谢谢。