我已经创建了一个弹出窗口,在里面有两个按钮。我想在单击弹出窗口内的按钮时关闭弹出窗口。
这是我的代码: FirstViewController:
第二个视图控制器:
这是我的代码: FirstViewController:
@IBAction func bar_button(_ sender: UIBarButtonItem) {
let vc = storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as!
SecondViewController
vc.preferredContentSize = CGSize(width: 200,height:80)
let navController = UINavigationController(rootViewController: vc)
navController.modalPresentationStyle = UIModalPresentationStyle.popover
let popover = navController.popoverPresentationController
popover?.delegate = self
popover?.barButtonItem = sender as! UIBarButtonItem
self.present(navController, animated: true, completion: nil)
}
第二个视图控制器:
@IBAction func second_button(_ sender: UIButton) {
//want to dismiss popover when button clicked
}
@IBAction func second_button(_ sender: UIButton) {
//want to dismiss popover when button clicked
}