Presenting Modal ViewController from (Table)ViewController inside a NavigationController inside a TabBarController

时间:2016-07-11 23:17:24

标签: ios cocoa-touch uinavigationcontroller uitabbarcontroller modalviewcontroller

When I try presenting the modal controller right from the table view controller (could be a normal view controller as well), it appears behind the tab bar and looks quite ugly as I'm using a blur effect on it. I am using a navigation controller because I need to have a bar at the top and, after research, found that's the best way to do it.

I have found that doing something like:

self.parent?.parent?.present(ModelViewController(), animated: true, completion: nil)

when wanting to present the modal controller works. However, I imagine this isn't very safe. What is the correct way of doing this?

1 个答案:

答案 0 :(得分:0)

为了让ModalViewController显示在标签栏前面,其modalPresentationStyle必须设置为overFullScreen。因此,例如在初始化ModalViewController时:

self.modalPresentationStyle = .overFullScreen(Swift 3语法)