質問編集履歴

2

解決:StoryBoadとソースを添付

2017/05/10 17:11

投稿

i-yamaguchi
i-yamaguchi

スコア7

test CHANGED
File without changes
test CHANGED
@@ -55,3 +55,169 @@
55
55
 
56
56
 
57
57
  初めて投稿します。至らぬ点などありましたらお知らせください。宜しくお願いします。
58
+
59
+
60
+
61
+ ###解決後ソース
62
+
63
+ ![イメージ説明](1a4dfe7119ca1cb980833a9f44799e4a.png)
64
+
65
+ ```swift
66
+
67
+
68
+
69
+ import UIKit
70
+
71
+
72
+
73
+ class ViewController: UIViewController, Modal1ViewControllerDelegate {
74
+
75
+
76
+
77
+ override func viewDidLoad() {
78
+
79
+ super.viewDidLoad()
80
+
81
+ }
82
+
83
+
84
+
85
+ override func didReceiveMemoryWarning() {
86
+
87
+ super.didReceiveMemoryWarning()
88
+
89
+ }
90
+
91
+
92
+
93
+ @IBAction func goBack(_ segue:UIStoryboardSegue) {}
94
+
95
+
96
+
97
+ @IBAction func goNext(_ sender:UIButton) {
98
+
99
+ let next = storyboard!.instantiateViewController(withIdentifier: "nextView")
100
+
101
+ self.present(next,animated: true, completion: nil)
102
+
103
+ }
104
+
105
+
106
+
107
+ // セグエ遷移用に追加 ↓↓↓
108
+
109
+ @IBAction func goNextBySegue(_ sender:UIButton) {
110
+
111
+ performSegue(withIdentifier: "nextSegue", sender: nil)
112
+
113
+ }
114
+
115
+
116
+
117
+ func goToNextPage() {
118
+
119
+ print("Modal1ViewControllerのdelegate")
120
+
121
+ performSegue(withIdentifier: "nextSegue2", sender: nil)
122
+
123
+ }
124
+
125
+
126
+
127
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
128
+
129
+ if(segue.identifier == "nextSegue"){
130
+
131
+ print("aaa")
132
+
133
+ let modal1ViewController = segue.destination as! Modal1ViewController
134
+
135
+ modal1ViewController.delegate = self
136
+
137
+ }else if(segue.identifier == "nextSegue2"){
138
+
139
+ print("bbb")
140
+
141
+ }
142
+
143
+ }
144
+
145
+ }
146
+
147
+ ```
148
+
149
+ ```swift
150
+
151
+ import UIKit
152
+
153
+
154
+
155
+ protocol Modal1ViewControllerDelegate: class {
156
+
157
+ func goToNextPage()
158
+
159
+ }
160
+
161
+
162
+
163
+ class Modal1ViewController: UIViewController {
164
+
165
+ weak var delegate: Modal1ViewControllerDelegate?
166
+
167
+
168
+
169
+ override func viewDidLoad() {
170
+
171
+ super.viewDidLoad()
172
+
173
+ }
174
+
175
+
176
+
177
+ override func didReceiveMemoryWarning() {
178
+
179
+ super.didReceiveMemoryWarning()
180
+
181
+ }
182
+
183
+
184
+
185
+ @IBAction func didTappedNextPage(_ sender: Any) {
186
+
187
+ self.dismiss(animated: true, completion: nil)
188
+
189
+ self.delegate?.goToNextPage()
190
+
191
+ }
192
+
193
+ }
194
+
195
+ ```
196
+
197
+ ```swift
198
+
199
+ import UIKit
200
+
201
+
202
+
203
+ class Modal2ViewController: UIViewController {
204
+
205
+
206
+
207
+ override func viewDidLoad() {
208
+
209
+ super.viewDidLoad()
210
+
211
+ }
212
+
213
+
214
+
215
+ override func didReceiveMemoryWarning() {
216
+
217
+ super.didReceiveMemoryWarning()
218
+
219
+ }
220
+
221
+ }
222
+
223
+ ```

1

【※追加情報】を付記しました。

2017/05/10 17:11

投稿

i-yamaguchi
i-yamaguchi

スコア7

test CHANGED
File without changes
test CHANGED
@@ -34,6 +34,12 @@
34
34
 
35
35
 
36
36
 
37
+ 【※追加情報】
38
+
39
+ <3>で閉じる必要はあります。モーダル表示する際、背景を透過しています。<4>で画面を表示した際に、<3>の画面を背景に見せたくありません。
40
+
41
+ NavigationControllerは未使用です。
42
+
37
43
 
38
44
 
39
45
  ###発生している問題・エラーメッセージ