PopoverPresentationController 为零

2024-01-15

创建了一个单视图应用程序,我在其中放置了一个按钮。

现在单击按钮我需要将 tableView 显示为弹出窗口。 TableViewController 是在 xib 中创建的。

问题是 tableViewController.popoverPresentationController 始终为 nil,请参见下面的代码

     let filterVC =  TableViewController(nibName: "TableViewController", bundle: nil)
    var filterDistanceViewController = UINavigationController(rootViewController: filterVC)
    filterDistanceViewController.preferredContentSize = CGSize(width: 300, height: 200)
    let popoverPresentationViewController = filterDistanceViewController.popoverPresentationController
    popoverPresentationViewController?.permittedArrowDirections = .any


    if let pop = filterDistanceViewController.popoverPresentationController {
        pop.delegate = self
    }

在上面的代码中 filterDistanceViewController.popoverPresentationController 始终为零

任何正确方向的暗示都将受到高度赞赏。


直到您设置了modalPresentationStyle在你的 VC 上,popoverPresentationController财产将是nil。确保您设置了modalPresentationStyle在访问之前。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PopoverPresentationController 为零 的相关文章

随机推荐