Black screen after presenting modal view controller in current context from UITabBarController

后端 未结 9 1691
终归单人心
终归单人心 2020-12-04 18:53

My root view controller is a UITabBarController. I\'m trying to present a modal view controller over one of the tab bar controller\'s view controllers, but still allow the

9条回答
  •  無奈伤痛
    2020-12-04 19:35

    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

提交回复
热议问题