Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Swift以编程方式在iOS中呈现popover?_Ios_Swift - Fatal编程技术网

如何使用Swift以编程方式在iOS中呈现popover?

如何使用Swift以编程方式在iOS中呈现popover?,ios,swift,Ios,Swift,我的目标是以编程方式将UIViewController呈现为popover func clickButton() { //What should I do here? } 正如您所看到的,转换样式设置为交叉融合,演示文稿设置为当前上下文中的。因此,从技术上讲,如果我单击按钮,转换将起作用,我的目标是以编程方式进行转换 func clickButton() { //What should I do here? } 如何在单击按钮上以编程方式显示po

我的目标是以编程方式将UIViewController呈现为popover

func clickButton() {
     //What should I do here?   


 }

正如您所看到的,转换样式设置为
交叉融合
,演示文稿设置为当前上下文中的
。因此,从技术上讲,如果我单击按钮,转换将起作用,我的目标是以编程方式进行转换

func clickButton() {
     //What should I do here?   


 }
如何在
单击按钮上以编程方式显示popover?

您可以尝试以下方法:

let rateViewController = RatePopupVC()
rateViewController.modalTransitionStyle = .crossDissolve
rateViewController.modalPresentationStyle = .overCurrentContext
self.present(rateViewController, animated: true, completion: nil)
如果要以编程方式关闭它

内硬聚氯乙烯

self.dismiss(animated: true, completion: nil)
您可以尝试以下方法:

let rateViewController = RatePopupVC()
rateViewController.modalTransitionStyle = .crossDissolve
rateViewController.modalPresentationStyle = .overCurrentContext
self.present(rateViewController, animated: true, completion: nil)
如果要以编程方式关闭它

内硬聚氯乙烯

self.dismiss(animated: true, completion: nil)
试试这个:

func clickButton() {

    let vc : PopupVC = storyboard!.instantiateViewControllerWithIdentifier("PopupVCID") as! PopupVC
    vc.modalTransitionStyle   = UIModalTransitionStyleCrossDissolve;
    self.presentViewController(vc, animated: true, completion: nil)
}
试试这个:

func clickButton() {

    let vc : PopupVC = storyboard!.instantiateViewControllerWithIdentifier("PopupVCID") as! PopupVC
    vc.modalTransitionStyle   = UIModalTransitionStyleCrossDissolve;
    self.presentViewController(vc, animated: true, completion: nil)
}

如果您以模态方式呈现视图控制器。你可以这样做

func clickButton() {
    if let vc = self.storyboard?.instantiateViewController(withIdentifier:"YOUR_VIEW_CONTROLLER_ID") {
        vc.modalTransitionStyle   = .crossDissolve;
        vc.modalPresentationStyle = .overCurrentContext
        self.present(vc, animated: true, completion: nil)
    }
}

如果您以模态方式呈现视图控制器。你可以这样做

func clickButton() {
    if let vc = self.storyboard?.instantiateViewController(withIdentifier:"YOUR_VIEW_CONTROLLER_ID") {
        vc.modalTransitionStyle   = .crossDissolve;
        vc.modalPresentationStyle = .overCurrentContext
        self.present(vc, animated: true, completion: nil)
    }
}
试试下面的代码

let popupview = storyboard?.instantiateViewController(withIdentifier: "YourViewController")
popupview.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
self.addChildViewController(popupview)
self.view.addSubview(popupview.view)
popupview.didMove(toParentViewController: popupview)
试试下面的代码

let popupview = storyboard?.instantiateViewController(withIdentifier: "YourViewController")
popupview.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
self.addChildViewController(popupview)
self.view.addSubview(popupview.view)
popupview.didMove(toParentViewController: popupview)

所以你在故事板中定义了它,但想让它以编程方式查看?或者想编写代码并按编程方式查看它?也可以尝试以下方法之一:所以你在故事板中定义了它,但想让它按编程方式查看?或者想编写代码并通过编程方式将其推送到视图?也可以尝试以下方法之一:如何传递数据?它是
vc.profileImage
?如果我想在
PopViewController
本身的函数上传递数据怎么办?数据是
vc.profileImage
?如果我想在
PopViewController
本身的函数上传递数据,该怎么办