popover doesn't display on iphone

前提是你 提交于 2020-01-07 07:25:12

问题


I followed this UIPopoverPresentationController on iPhone doesn't produce popover but doesn't produce popover on iphone. Here is the code of 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
    }
}

I am not able to show new viewcontroller using present as popover in iphone. (ios 10/xcode8)

After clicking on button secondViewController should popover on that button.


回答1:


After using this delegate method it is producing popover on iphone.

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

    return UIModalPresentationStyle.none
}


来源:https://stackoverflow.com/questions/41407782/popover-doesnt-display-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!