質問編集履歴

9

編集

2018/09/10 11:49

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -89,7 +89,3 @@
89
89
  class ColorPickerViewController: UIViewController, UIPopoverPresentationControllerDelegate
90
90
 
91
91
  ```
92
-
93
-
94
-
95
- 今回の質問が少し分かりづらい感じになってしまったので、もう少しやりたい事を簡単にまとめて質問し直しているのでそちらも目を通していただけると大変助かります。(https://teratail.com/questions/145617)こちらです。

8

編集

2018/09/10 11:49

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -1,12 +1,10 @@
1
- 以下のライブラリのデモ参考にカラーピックアップのview出したいです。
1
+ 以下のライブラリを使ってカラーピッカー表示させたいです。
2
-
3
-
4
2
 
5
3
  https://github.com/malkouz/MKColorPicker
6
4
 
7
5
 
8
6
 
9
- デモ流れとしては以下のにVCでColorPickerViewControllerをインスタンス化、それをself.present(colorPicker, animated: true, completion: nil)で呼んでる流れです。
7
+ gitにあるサンプルを参考にしています。そのサンプルで以下のようにVCで実行て表示してす。
10
8
 
11
9
 
12
10
 
@@ -25,6 +23,8 @@
25
23
 
26
24
 
27
25
  @IBAction func showPicker(sender: UIButton) {
26
+
27
+ /*******省略******************/
28
28
 
29
29
    if let popoverController = colorPicker.popoverPresentationController{
30
30
 
@@ -50,89 +50,21 @@
50
50
 
51
51
  ```
52
52
 
53
+ 最後にself.present(colorPicker, animated: true, completion: nil)で表示しているような形です。
53
54
 
54
-
55
- 自分の場合はこのshowPickerのボタンを、ポップアップで出てくるcontainerViewに乗せて実行したいです。
56
-
57
-
58
-
59
- ```swift
60
-
61
- class PopupView: UIView, PopupViewContainable, Nibable {
62
-
63
-
64
-
65
- /*******省略******************/
66
-
67
-
68
-
69
- @IBOutlet weak var containerView: UIView! {
70
-
71
- didSet {
72
-
73
- containerView.layer.masksToBounds = true
74
-
75
- }
76
-
77
- }
78
-
79
- @IBAction func showPicker(sender: UIButton) {
80
-
81
-   
82
-
83
-   if let popoverController = colorPicker.popoverPresentationController{
84
-
85
- popoverController.delegate = colorPicker
86
-
87
- popoverController.permittedArrowDirections = .any
88
-
89
- // popoverVC.delegate = self
90
-
91
- popoverController.sourceView = sender
92
-
93
- popoverController.sourceRect = sender.bounds
94
-
95
- }
96
-
97
-
98
-
99
- self.present(colorPicker, animated: true, completion: nil)//Value of type 'PopupView' has no member 'present'
100
-
101
- }
102
-
103
- }
104
-
105
- ```
106
-
107
-
108
-
109
- このクラスはUIViewControllerを継承している訳ではないので以上の様にpresentは実行できません。この場合どうすれば良いでしょうか?PopupViewにUIViewControllerを継承させるとそこのエラーは取れても他でエラー出てきてしまいます。ColorPickerViewController()はUIViewControllerを継承したクラスですが、UIViewControllerを表示させる方法がpresent以外であったりしますか??
110
-
111
-
112
-
113
-
114
-
115
- ーーーーー追記ーーーーーーーーー
116
-
117
- すみませんどの様に表示しているかよくわかってなかったのですが、ColorPickerViewControllerは以下の様にUIPopoverPresentationControllerDelegateも用いている様なのでこっちの機能なのかもしれませんが、だとしてもどの様に表示すれば良いでしょうか?
118
-
119
-
120
-
121
- ```swift
122
-
123
- open class ColorPickerViewController: UIViewController, UIPopoverPresentationControllerDelegate {
124
-
125
-    
126
-
127
-    /*******省略******************/
128
-
129
- }
130
-
131
- ```
132
-
133
- 因みにさらに詳しくいうと以下のモジュールのポップアップ上にshowPickerのボタンを乗せて実行したいといった感じです!
55
+ 自分の場合は以下のライブラリのポップアップビューの上にshowPickerを置きたいです。
134
56
 
135
57
  https://github.com/shin8484/PopupWindow
58
+
59
+ こちらのライブラリではDemoのRegisterPopupViewというクラスがありますがそれはUIviewを継承したクラスです。そこで以上のように最後にself.presentで表示したいのですが、self.presentはUIViewControllerのメソッドなので実行できません。しかしRegisterPopupViewのUIviewをUIViewControllerに変えると他のところで色々エラーが出てしまいます。どうすればこのpopup上に最初のライブラリのサンプルのshowPickerを置いて実行できるでしょうか?
60
+
61
+ 参考までにやりたいことの確認ですが、以下のポップアップに
62
+
63
+ ![イメージ説明](64205934edf533aa2a6f31805f428723.png)
64
+
65
+ 以下のようなボタンを表示さて、popoverPresentationControllerを実行したいです。
66
+
67
+ ![イメージ説明](258e3f591c0d44f90f9d40f56f40655f.png)
136
68
 
137
69
 
138
70
 

7

編集

2018/09/10 11:47

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -150,4 +150,14 @@
150
150
 
151
151
  ```
152
152
 
153
+ colorPicker.presentとなるという事でしょうか?またちなみにColorPickerViewController()は以下のようなクラスを継承しています。
154
+
155
+ ``` Swift
156
+
157
+ class ColorPickerViewController: UIViewController, UIPopoverPresentationControllerDelegate
158
+
159
+ ```
160
+
161
+
162
+
153
- colorPicker.presentとなるという事でしょうか?今回の質問が少し分かりづらい感じになってしまったので、もう少しやりたい事を簡単にまとめて質問し直しているのでそちらも目を通していただけると大変助かります。(https://teratail.com/questions/145617)こちらです。
163
+ 今回の質問が少し分かりづらい感じになってしまったので、もう少しやりたい事を簡単にまとめて質問し直しているのでそちらも目を通していただけると大変助かります。(https://teratail.com/questions/145617)こちらです。

6

追記

2018/09/10 07:48

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -133,3 +133,21 @@
133
133
  因みにさらに詳しくいうと以下のモジュールのポップアップ上にshowPickerのボタンを乗せて実行したいといった感じです!
134
134
 
135
135
  https://github.com/shin8484/PopupWindow
136
+
137
+
138
+
139
+
140
+
141
+ ーーーーーーーー追記、fuzzball様へーーーーーーーーーーーーー
142
+
143
+ 仮にVCで実行するとすると、 self.present(colorPicker, animated: true, completion: nil)というようになりcolorPickerをpresentしたい訳ですが、そのインスタンスからpresentするという事は以下のようにインスタンス化したとして、
144
+
145
+
146
+
147
+ ```Swift
148
+
149
+ let colorPicker = ColorPickerViewController()
150
+
151
+ ```
152
+
153
+ colorPicker.presentとなるという事でしょうか?今回の質問が少し分かりづらい感じになってしまったので、もう少しやりたい事を簡単にまとめて質問し直しているのでそちらも目を通していただけると大変助かります。(https://teratail.com/questions/145617)こちらです。

5

追記

2018/09/10 07:44

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -52,7 +52,7 @@
52
52
 
53
53
 
54
54
 
55
- 自分の場合はこのcolor_pickのボタンを、ポップアップで出てくるcontainerViewに乗せて実行したいです。
55
+ 自分の場合はこのshowPickerのボタンを、ポップアップで出てくるcontainerViewに乗せて実行したいです。
56
56
 
57
57
 
58
58
 
@@ -129,3 +129,7 @@
129
129
  }
130
130
 
131
131
  ```
132
+
133
+ 因みにさらに詳しくいうと以下のモジュールのポップアップ上にshowPickerのボタンを乗せて実行したいといった感じです!
134
+
135
+ https://github.com/shin8484/PopupWindow

4

追記

2018/09/08 00:43

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -107,3 +107,25 @@
107
107
 
108
108
 
109
109
  このクラスはUIViewControllerを継承している訳ではないので以上の様にpresentは実行できません。この場合どうすれば良いでしょうか?PopupViewにUIViewControllerを継承させるとそこのエラーは取れても他でエラー出てきてしまいます。ColorPickerViewController()はUIViewControllerを継承したクラスですが、UIViewControllerを表示させる方法がpresent以外であったりしますか??
110
+
111
+
112
+
113
+
114
+
115
+ ーーーーー追記ーーーーーーーーー
116
+
117
+ すみませんどの様に表示しているかよくわかってなかったのですが、ColorPickerViewControllerは以下の様にUIPopoverPresentationControllerDelegateも用いている様なのでこっちの機能なのかもしれませんが、だとしてもどの様に表示すれば良いでしょうか?
118
+
119
+
120
+
121
+ ```swift
122
+
123
+ open class ColorPickerViewController: UIViewController, UIPopoverPresentationControllerDelegate {
124
+
125
+    
126
+
127
+    /*******省略******************/
128
+
129
+ }
130
+
131
+ ```

3

編集

2018/09/08 00:02

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -25,6 +25,20 @@
25
25
 
26
26
 
27
27
  @IBAction func showPicker(sender: UIButton) {
28
+
29
+   if let popoverController = colorPicker.popoverPresentationController{
30
+
31
+ popoverController.delegate = colorPicker
32
+
33
+ popoverController.permittedArrowDirections = .any
34
+
35
+ // popoverVC.delegate = self
36
+
37
+ popoverController.sourceView = sender
38
+
39
+ popoverController.sourceRect = sender.bounds
40
+
41
+ }
28
42
 
29
43
  self.present(colorPicker, animated: true, completion: nil)
30
44
 
@@ -64,6 +78,24 @@
64
78
 
65
79
  @IBAction func showPicker(sender: UIButton) {
66
80
 
81
+   
82
+
83
+   if let popoverController = colorPicker.popoverPresentationController{
84
+
85
+ popoverController.delegate = colorPicker
86
+
87
+ popoverController.permittedArrowDirections = .any
88
+
89
+ // popoverVC.delegate = self
90
+
91
+ popoverController.sourceView = sender
92
+
93
+ popoverController.sourceRect = sender.bounds
94
+
95
+ }
96
+
97
+
98
+
67
99
  self.present(colorPicker, animated: true, completion: nil)//Value of type 'PopupView' has no member 'present'
68
100
 
69
101
  }

2

誤字

2018/09/07 13:27

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -38,7 +38,7 @@
38
38
 
39
39
 
40
40
 
41
- 自分の場合はこのcolor_pickのボタンをポップアップで出てくるcontainerViewに乗せて実行したいです。
41
+ 自分の場合はこのcolor_pickのボタンをポップアップで出てくるcontainerViewに乗せて実行したいです。
42
42
 
43
43
 
44
44
 

1

誤字

2018/09/07 13:05

投稿

Hayato1201
Hayato1201

スコア220

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- デモの流れとしては以下の様にVCでColorPickerViewControllerをインスタンス化し、それをself.present(colorPicker, animated: true, completion: nil)でんでいる流れです。
9
+ デモの流れとしては以下の様にVCでColorPickerViewControllerをインスタンス化し、それをself.present(colorPicker, animated: true, completion: nil)でんでいる流れです。
10
10
 
11
11
 
12
12