ボタンがあるセルを持つテーブルビューコントローラがあります。UIPopoverPresentationController内のボタンをクリックすると、ビューコントローラに移動します。
このボタンをクリックすると、UIPopoverPresentationControllerとしてビューコントローラが表示されます。
このポップオーバーコントローラには、YESとNOの2つのボタンがあります。
はいクリックすると、別のView Controllerにセグをしたいのですが、いいえをクリックすると、ポップオーバーコントローラが却下されます。
いいえクリックするとポップオーバーが解除されますが、クリックすると必要なビューコントローラに移動しません。
ビューコントローラのview()メソッドが呼び出されましたが、問題は、新しいView Controllerが表示されていないことです。 YES、ポップオーバーが閉じますをクリックするだけで
が、次の以前のビューコントローラに
ままでは
@IBAction func onTapNoButton(_ sender: UIButton) {
self.dismiss(animated: true, completion: {})
}
@IBAction func onTapYesButton(_ sender: UIButton) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "View") as! ViewController
present(viewController, animated: true, completion: nil)
}
クラス
func onTapPickButton(sender: UIButton) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let popoverViewController = storyboard.instantiateViewController(withIdentifier: "ConfirmDialogViewController") as! ConfirmDialogViewController
popoverViewController.preferredContentSize = CGSize(width: view.frame.width/1.33, height: view.frame.height/2.34)
popoverViewController.modalPresentationStyle = UIModalPresentationStyle.popover
let popover: UIPopoverPresentationController = popoverViewController.popoverPresentationController!
popover.sourceView = self.view
popover.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
popover.delegate = self
present(popoverViewController, animated: true, completion: nil)
}
ポップオーバービューコントローラクラス
TableViewController私のコードです
ご協力いただければ幸いです。ありがとうございました。ボタンアクションYESで
次のエラーが発生しています。を上に表示しようとしましたが、ビューはウィンドウ階層にありません! –