I want to show a customised alert panel over my app, but have the previous UIViewController visible in the background. I was hoping to show this as a modal view controller. How do I do this without the previous UIViewController turning black and disappearing?
navigationController. modalPresentationStyle = UIModalPresentationCurrentContext; then it works and my view is transparent.
The view's window property is non-nil if a view is currently visible, so check the main view in the view controller: Invoking the view method causes the view to load (if it is not loaded) which is unnecessary and may be undesirable. It would be better to check first to see if it is already loaded.
Instead of showing the new vc as a modal vc, you need to add it as child view controller:
AlertPanelVC *alertVC = ...
[self addChildViewController: alertVC];
alertVC.view.frame = ...; //or something equivalent if you're using auto layout
[self.view addSubview: alertVC.view];
[alertVC didMoveToParentViewController: self];
To dismiss it:
[alertVC willMoveToParentViewController:nil];
[alertVC.view removeFromSuperview];
[alertVC removeFromParentViewController];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With