目前模态不正确调整视图

时间:2017-02-14 16:03:02

标签: ios swift

我正在尝试从TableViewController内的按钮呈现ViewController(嵌入在NavigationController中)。呈现的ViewController应该是TableViewController的一半高度。我已尝试使用下面的代码但它似乎不起作用(Swift 3)。有人可以帮忙吗?谢谢!

is_prepare_done

1 个答案:

答案 0 :(得分:0)

你有:

func presentationControllerForPresentedViewController(
    presented: UIViewController, 
    presentingViewController presenting: UIViewController!, 
    sourceViewController source: UIViewController) 
    -> UIPresentationController? {

永远不会调用该方法,因为在Swift 3中它并不对应于Cocoa所知道的任何方法。 (我很惊讶你没有报告从编译器收到关于此的警告。)

您可能打算实施presentationController(forPresented:presenting:source:),如下所示:

func presentationController(
    forPresented presented: UIViewController, 
    presenting: UIViewController?, 
    source: UIViewController) 
    -> UIPresentationController? {

但即使不会被调用,因为您尚未将呈现的视图控制器modalPresentationStyle设置为.custom

相关问题