let db = Firestore.firestore()
db.collection("Orders").document(Flag1!).getDocument() { (docSnapshot, err) in
if let err=err {
print("Error getting documents: \(err)")
} else {
guard let docSnapshot = docSnapshot, (docSnapshot.exists) else { return }
let myData = docSnapshot.data()
let status:String = myData!["Status"] as? String ?? ""
if status == "OrderModified"{
var topWindow: UIWindow? = UIWindow(frame: UIScreen.main.bounds)
topWindow?.rootViewController = UIViewController()
topWindow?.windowLevel = UIWindow.Level.alert + 1
let alert: UIAlertController = UIAlertController(title: "Message", message: "this order was modified", preferredStyle: .alert)
alert.addAction(UIAlertAction.init(title: "OK", style: .default, handler: { (alertAction) in
topWindow?.isHidden = true
topWindow = nil
}))
topWindow?.makeKeyAndVisible()
topWindow?.rootViewController?.present(alert, animated: true, completion:nil)
}else{
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let presentViewController = storyBoard.instantiateViewController(withIdentifier: "AltWhenNoPs") as! AltWhenNoPs
presentViewController.orderid = Flag1!
let navigationController = UINavigationController(rootViewController: presentViewController)
self.window?.rootViewController = navigationController
}
}
}
我在appdelegate中编写了代码,用于在单击通知时导航到特定的视图控制器,上面的代码效果很好,但是问题是当我单击通知时,标签栏不可见。为什么它隐藏了?谁能建议我我在哪里做错了。提前致谢。