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. enter image description here

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

Try presenting the view controller in application window. I had a similar problem which was fixed by below code:

    let myNewVC = mainStoryBoard.instantiateViewController(withIdentifier: "MyNewVCId") as! MyNewVC
    let navController = UINavigationController(rootViewController: myNewVC)
    navController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext    

    let appDelegate = UIApplication.shared.delegate as? AppDelegate
    appDelegate?.window?.rootViewController?.present(navController, animated: true, completion: nil)

Hope this helps you too.

I reproduced your problem and found a solution. It does not involve changing the segue method or changing some attributes in the storyboard.


But before going to the solution I would like to add that the purpose of modally presented viewcontrollers is to distrupt the actual flow of the app and present some extra contextual information or some actionable contents for the presenting vc. Simply put it is very logical and actually recommended to cover the tab bar when presenting a view controller modally. There are lots of good examples of it in the app store.

Having said that here is a solution I propose.


I believe the problem lies in the way UITabBarController handles its view hierarchy.

What I did was explicitly dismiss the modally presented view controller before the tab was changed. This made the presenting view controller persist in the view hierarchy of the UITabBarViewController before the tab bar switches to new tab.

In the "viewWillDisappear" method of your modally presented ViewController add this.

- (void)viewWillDisappear:(BOOL)animated {
    [self dismissViewControllerAnimated:true completion:^{
    [super viewWillDisappear:animated];

i had this problem : when i present my ModalController it takes transparent background and when i changed the tab to next one in tabBarController and getBack to previous one the transparent background was gone and and there is a bad black background after research i found the point the point is this:

self.definesPresentationContext = true

the self is not modal controller self is that presenting controller for modalController and another point is .overCurrentContext like this

** self.definesPresentationContext = true ** modalController.modalPresentationStyle = .overCurrentContext self.present(modalController, animated: true, completion: nil)

Having a similiar issue with my tab controller, however like the comments, I suggest changing the segue to a push or a show segue. This will allow that tab to remain in tact with the new view shown in place of the old view when switching to other tabs. If aesthetics is an issue you can make a custom navigation controller to customize the appearance of the new view.

I have same problem in currently live swift project. I have did workaround on that.

Then finally i have used NSNotificationCenter and dismiss that view controller when tab is changed to solve this problem.

I have referenced tabbar controller in AppDelegate and set delegate there.

let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

let tabbarcontroller = storyboard.instantiateViewControllerWithIdentifier("MyTabBarController") as! UITabBarController

tabbarcontroller.delegate = self

And it's delegate as

//MARK: - Tabbar controller delegate

extension AppDelegate : UITabBarControllerDelegate {

    func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {

        NSNotificationCenter.defaultCenter().postNotificationName("TabBarTabChanged", object: nil)

Then I have add observer in my presented view controller as

override func viewDidLoad() {

        // Do any additional setup after loading the view.
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(PreviewPlaceVC.BackClickAction(_:)), name: "TabBarTabChanged", object: nil)

// MARK: - Button Click Actions

@IBAction func BackClickAction(sender: AnyObject) {
     self.dismissViewControllerAnimated(true, completion: nil)

And it's work fine for me. Not a proper solution I think to dismiss view controller on tab change event, but it is ok to dismiss rather than black screen which also breaks navigation that time.