Closed justdan0227 closed 6 years ago
No, like SW, the library does not handle deinit or dealloc. View controllers (left, main, right) are removed from memory by ARC when they are removed from their parent view controller (i.e PBRevealViewController). If you want them not to be removed from memory you have to keep a strong reference to them.
Ok but there is my issue. It appears that even a simple controller instantiated from the menu over and over again does not dealoc/deinit ?
I will have a check
Here is a sample. You can see that the "deinitializer" is called immediately before the class instance (Main or Second View Controller) is deallocated, each time you replace the main view controller. Here you can perform additional cleanup if needed.
Ok this look promising. Can you tell me why my button on my Main ViewController that is supposed to invoke the SecondViewController is somehow just calling deinit of the Second? PBRevealDeinit_dan.zip
The menu is not open then the second view controller is not pushed and the main view controller is not replaced so the second view controller is deallocated immediately.
@objc open func pushMainViewController(_ mainViewController: UIViewController, animated: Bool) {
var operation: PBRevealControllerOperation
if isLeftViewOpen {
operation = .pushMainControllerFromLeft
}
else if isRightViewOpen {
operation = .pushMainControllerFromRight
}
else {
return
}
let fromViewController: UIViewController? = self.mainViewController
self.mainViewController = mainViewController
_pushFromViewController(fromViewController!, toViewController: mainViewController, operation: operation, animated: animated)
}
In this case you have to replace the main view controller instead of pushing it:
@IBAction func myButtonPressed(_ sender: Any) {
let controller = storyboard?.instantiateViewController(withIdentifier: "SecondViewController")
let nc = UINavigationController(rootViewController: controller!)
//revealViewController()?.pushMainViewController(nc, animated:true)
revealViewController()?.setMainViewController(nc, animated: true)
}
ahhhh got it! Thanks.. so much easier than SWReveal!
Great! I will close this issue. Feel free to open another one if needed.
Does this library deinit viewcontrollers unlike SWReveal? I just noticed that all of my viewControllers are sticking around and looking for a more up to date drawer library for IOS.