wxxsw / SwiftTheme

🎨 Powerful theme/skin manager for iOS 9+ 主题/换肤, 暗色模式
MIT License
2.52k stars 306 forks source link

NavigationBar disappearing #99

Closed Quailcreek closed 5 years ago

Quailcreek commented 5 years ago

I am setting up some user preferences to allow the user to customize the side menu. I have the customization items set up on the preferences VC with a UISwitch for each item. I found that when the item is changed on/off the new setting is not realized until the rootViewController is reinitiated. To try to fix this I have a function that presents an alert. The alert contains code to perform the re-instantiation of the root controller.

The problem I had at first was the "contentViewController" for the side menu was hard coded so when the alert code ran, the contentViewController/Home VC was shown instead of staying on the preferences VC. To remedy this problem I created a variable "thecCntentViewController" to hold the ID of the "contentViewController". I set thecCntentViewController to "Preferences_VC" and that now keeps the Preferences VC on the screen when the UISwitch is changed.

I have everything working except for one glitch. The NavigationBar disappears when the alert code runs. The Preferences VC is imbedded in a NavigationColtroller. Can you tell me what is need to change to keep the navigationBar from disappearing?

`func presentAlert() { let alert = UIAlertController(title: "Configure the Side Menu", message: "The Side Menu needs to be reloaded after modifying key preferences.", preferredStyle: .alert) let confirmButton = UIAlertAction(title: "OK", style: .default) { (_) in thecCntentViewController = "Preferences_VC" let sideMenuController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "rootController") UIApplication.shared.keyWindow?.rootViewController = sideMenuController

    }
    alert.addAction(confirmButton)
    present(alert, animated: true, completion: nil)
}`
wxxsw commented 5 years ago

Issues not related to SwiftTheme