1
我爲我的應用程序強制更新,但是當我回去時不更新應用AlertController消失,因爲它可以固定與AlertController
如果你知道其他的選項,使強制更新強制更新應用程序,然後寫
感謝您的幫助
func version(){
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
self.labelVersion = version
dowloand()
}
}
func dowloand(){
...JSON request
if labelVersion == JsonVersion{
showTopLevelAlert()
} else {
}
}
func showTopLevelAlert() {
let alertController = UIAlertController (title: "Доступно обновление", message: "Для продолжения работы с приложением необходимо обновиться.", preferredStyle: .alert)
let Update = UIAlertAction(title: "Обновить", style: .default, handler:{(action) in
let url = URL(string: "http://appstore.com/")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
})
alertController.addAction(Update)
let alertWindow = UIWindow(frame: UIScreen.main.bounds)
alertWindow.rootViewController = UIViewController()
alertWindow.windowLevel = UIWindowLevelAlert + 1;
alertWindow.makeKeyAndVisible()
alertWindow.rootViewController?.present(alertController, animated: true, completion: nil)
}
謝謝,一切正常,但第二個更快 – Vasya2014