[ad_1]
I’m experiencing some bizarre habits with a button I’m attempting to implement in my app. I’ve a ‘compose submit’ button that I’m including to the important thing window of the app. I need to create the button and conceal it in sure situations like when the navigation controller pushes a brand new view controller (i.e. clicking on a submit). The app is setup like this:
Fundamental is a storyboard that may be a customized UITabController of sort MainTabViewController that has 4 tabs, every a UINavigationController that has a container that’s of sort BaseViewController.
Within the viewDidLoad perform of MainTabViewController I create the compose button and add it to the important thing window as a subview like this:
func createButton(){
let keyWindow = UIApplication.shared.keyWindow
postButtonContainer = FanMenu...
keyWindow?.addSubview(postButtonContainer)
}
And in BaseViewController I exploit viewWillDisappear to cover the compose button (i.e. when submit is clicked on) after which viewWillAppear to point out the compose button by setting the isHidden to true or false.
override func viewWillDisappear(_ animated: Bool) {
tremendous.viewWillDisappear(animated)
ComposeButtonManager.shared.hidePostButton()
}
override func viewWillAppear(_ animated: Bool) {
tremendous.viewWillAppear(animated)
ComposeButtonManager.shared.showPostButton()
}
The difficulty is going on solely after I crash shut the app after booting up from Xcode. What’s taking place is that once I reopen after crash closing – the app will load fantastic and current the compose button, but when I navigate from a tab after which again to that very same tab, the compose button will not be displaying. And if I click on a submit and navigate again to BaseViewController subclass the button will re seem. I’m not certain why the button is hiding after the tab bar switches, when all of the UIViewControllers name to unhide the button when their view will seem.
[ad_2]
