以下のライブラリを使ってカラーピッカーを表示させたいです。
https://github.com/malkouz/MKColorPicker
このgitにあるサンプルを参考にしています。そのサンプルでは、以下のようにVCで実行して表示しています。
Swift
1 2class ViewController: UIViewController { 3 4let colorPicker = ColorPickerViewController() 5/*******省略******************/ 6 7@IBAction func showPicker(sender: UIButton) { 8/*******省略******************/ 9 if let popoverController = colorPicker.popoverPresentationController{ 10 popoverController.delegate = colorPicker 11 popoverController.permittedArrowDirections = .any 12 // popoverVC.delegate = self 13 popoverController.sourceView = sender 14 popoverController.sourceRect = sender.bounds 15 } 16 self.present(colorPicker, animated: true, completion: nil) 17} 18 19/*******省略******************/
最後にself.present(colorPicker, animated: true, completion: nil)で表示しているような形です。
自分の場合は以下のライブラリのポップアップビューの上にshowPickerを置きたいです。
https://github.com/shin8484/PopupWindow
こちらのライブラリではDemoのRegisterPopupViewというクラスがありますがそれはUIviewを継承したクラスです。そこで以上のように最後にself.presentで表示したいのですが、self.presentはUIViewControllerのメソッドなので実行できません。しかしRegisterPopupViewのUIviewをUIViewControllerに変えると他のところで色々エラーが出てしまいます。どうすればこのpopup上に最初のライブラリのサンプルのshowPickerを置いて実行できるでしょうか?
参考までにやりたいことの確認ですが、以下のポップアップに
以下のようなボタンを表示さて、popoverPresentationControllerを実行したいです。
ーーーーーーーー追記、fuzzball様へーーーーーーーーーーーーー
仮にVCで実行するとすると、 self.present(colorPicker, animated: true, completion: nil)というようになりcolorPickerをpresentしたい訳ですが、そのインスタンスからpresentするという事は以下のようにインスタンス化したとして、
Swift
1let colorPicker = ColorPickerViewController()
colorPicker.presentとなるという事でしょうか?またちなみにColorPickerViewController()は以下のようなクラスを継承しています。
Swift
1class ColorPickerViewController: UIViewController, UIPopoverPresentationControllerDelegate

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/10 07:45
2018/09/10 07:56 編集
2018/09/10 11:48
2018/09/11 00:09 編集
2018/09/11 00:10