Black screen after presenting modal view controller in current context from UITabBarController
I had the same issue and was able to solve it by setting self.definesPresentationContext = YES;
on the presenting view controller before presenting the modal VC. You can also set this in a storyboard, the checkbox is called "Defines Context" in Interface Builder.
Try to set your presentation style as 'Over Full Screen' instead of 'Over Current Context' in storyboard.
iOS 10+ & Swift 3+
I've very nice solution of this problem. Use, over full screen modal presentation style for a view controller, is being presented.
let storyboard = UIStoryboard(name: "Main", bundle: nil) // Replace “Main” with your storyboard name
if let viewController = storyboard?.instantiateViewController(withIdentifier: “viewController Identifier”) as? ViewController {
viewController.modalPresentationStyle = .overFullScreen
self.present(viewController, animated: false, completion: {
})
}
Over full screen will present your view controller over your tabbar (controller) by covering it. So, end-user can't switch tabbar (unless you perform operation programatically) tabbar items. User must close this view controller to switch tabbar.
If you are using segue, to present view controller then select 'Over Full Screen' from modal presentation style in Attribute inspection