popover不会在iphone上显示

时间:2016-12-31 11:11:47

标签: iphone uikit ios10 uipopovercontroller popover

我遵循了这个UIPopoverPresentationController on iPhone doesn't produce popover,但在iphone上没有产生弹出窗口。 这是viewcontroller的代码

class ViewController:UIViewController,UIPopoverPresentationControllerDelegate{

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        if segue.identifier == "second"{

            let secondVC = segue.destination
            let controller : UIPopoverPresentationController = secondVC.popoverPresentationController!
            controller.delegate = self
        }
    }

    /* Popover delegate method */
    func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
        return UIModalPresentationStyle.none
    }
}

我无法在iphone中使用present作为popover显示新的viewcontroller。 (ios 10 / xcode8)

After clicking on button secondViewController should popover on that button.

1 个答案:

答案 0 :(得分:0)

使用此委托方法后,它会在iphone上生成popover。

func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {

    return UIModalPresentationStyle.none
}