[英]how to cover the entire screen with a UIView using swift programatically
[英]How to Reload Entire app settings programatically in swift 2
我寫了一個應用程序,當默認設置更改時,我需要重新加載所有設置。
但是我沒有頭緒。 我嘗試重新啟動或重新加載第一個視圖控制器,但是它不起作用。 我的問題是我從核心數據中獲取所有視圖控制器並從中加載標簽,但是我必須關閉應用程序並重新啟動以查看更改。
任何想法如何做到這一點?
您的核心問題是更改設置后重新加載數據。 有很多方法可以達到這個目的。 一種是使用KVO觀察要更改的所有UI元素的設置。
還有另一種強制方式,使您不需要重新啟動應用程序。
因為您的所有數據都在viewControllers的init
方法之后使用。 無需重新加載第一個viewController,而是更新應用程序的rootViewController
並進行設置。
更改設置后。
if let tabBarController = UIApplication.sharedApplication().keyWindow?.rootViewController as? UITabBarViewController {
let naviController1 = UINavigationController(rootViewController: HomeViewController())
let naviController2 = UINavigationController(rootViewController: AccountViewController())
tabBarController.viewControllers = [naviController1, naviController2]
}
要么
UIApplication.sharedApplication().keyWindow?.rootViewController = YOURTabBarController()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.