回答編集履歴
3
修正
answer
CHANGED
@@ -5,9 +5,11 @@
|
|
5
5
|
|
6
6
|
// TopViewController
|
7
7
|
class TopViewController: UIViewController {
|
8
|
-
|
8
|
+
|
9
9
|
@IBAction func pushNext(sender: UIButton) {
|
10
|
-
self.
|
10
|
+
if let listView = self.storyboard?.instantiateViewControllerWithIdentifier("list") as? ListViewController {
|
11
|
+
self.navigationController?.pushViewController(listView, animated: true)
|
12
|
+
}
|
11
13
|
}
|
12
14
|
}
|
13
15
|
|
@@ -15,28 +17,21 @@
|
|
15
17
|
class ListViewController: UIViewController {
|
16
18
|
|
17
19
|
@IBAction func pushModal(sender: UIButton) {
|
18
|
-
self.performSegueWithIdentifier("modal", sender: nil)
|
19
|
-
}
|
20
|
-
|
21
|
-
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
22
|
-
if let modalView =
|
20
|
+
if let modalView = self.storyboard?.instantiateViewControllerWithIdentifier("modal") as? ModalViewController {
|
23
|
-
modalView.listView = self
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
func modalClose(modalView: ModalViewController) {
|
28
|
-
// ModalViewControllerを閉じる
|
29
|
-
modalView.dismissViewControllerAnimated(true) {
|
30
21
|
|
31
22
|
guard var history = self.navigationController?.viewControllers,
|
32
23
|
let detilView = self.storyboard?.instantiateViewControllerWithIdentifier("detail") as? DetailViewController,
|
33
|
-
let editView
|
24
|
+
let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController else {
|
34
|
-
|
25
|
+
return
|
35
26
|
}
|
36
27
|
|
37
28
|
history.append(detilView)
|
38
29
|
history.append(editView)
|
30
|
+
modalView.editView = editView
|
31
|
+
|
32
|
+
self.presentViewController(modalView, animated: true) {
|
39
|
-
|
33
|
+
self.navigationController?.setViewControllers(history, animated: false)
|
34
|
+
}
|
40
35
|
}
|
41
36
|
}
|
42
37
|
}
|
@@ -44,11 +39,11 @@
|
|
44
39
|
// ModalViewController
|
45
40
|
class ModalViewController: UIViewController {
|
46
41
|
|
47
|
-
weak var
|
42
|
+
weak var editView: EditiewController!
|
48
43
|
|
49
44
|
@IBAction func pushCloseButton(sender: UIButton) {
|
50
45
|
// 親のViewControllerからModalを閉じる
|
51
|
-
|
46
|
+
editView?.modalClose(self)
|
52
47
|
}
|
53
48
|
}
|
54
49
|
|
@@ -56,15 +51,19 @@
|
|
56
51
|
class DetailViewController: UIViewController {
|
57
52
|
|
58
53
|
@IBAction func pushNext(sender: UIButton) {
|
59
|
-
self.
|
54
|
+
if let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController {
|
55
|
+
self.navigationController?.pushViewController(editView, animated: true)
|
56
|
+
}
|
60
57
|
}
|
61
58
|
}
|
62
59
|
|
63
60
|
// EditViewController
|
64
61
|
class EditiewController: UIViewController {
|
65
62
|
|
66
|
-
|
63
|
+
var modalView: ModalViewController!
|
64
|
+
|
67
|
-
|
65
|
+
func modalClose(modalView: ModalViewController) {
|
66
|
+
modalView.dismissViewControllerAnimated(true, completion: nil)
|
68
67
|
}
|
69
68
|
}
|
70
69
|
```
|
2
修正
answer
CHANGED
@@ -27,16 +27,16 @@
|
|
27
27
|
func modalClose(modalView: ModalViewController) {
|
28
28
|
// ModalViewControllerを閉じる
|
29
29
|
modalView.dismissViewControllerAnimated(true) {
|
30
|
-
var history = self.navigationController?.viewControllers
|
31
30
|
|
31
|
+
guard var history = self.navigationController?.viewControllers,
|
32
|
-
|
32
|
+
let detilView = self.storyboard?.instantiateViewControllerWithIdentifier("detail") as? DetailViewController,
|
33
|
-
history?.append(detilView)
|
34
|
-
|
35
|
-
|
33
|
+
let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController else {
|
36
|
-
|
34
|
+
return
|
37
|
-
self.navigationController?.setViewControllers(history!, animated: true)
|
38
|
-
}
|
39
35
|
}
|
36
|
+
|
37
|
+
history.append(detilView)
|
38
|
+
history.append(editView)
|
39
|
+
self.navigationController?.setViewControllers(history, animated: true)
|
40
40
|
}
|
41
41
|
}
|
42
42
|
}
|
1
修正
answer
CHANGED
@@ -67,4 +67,7 @@
|
|
67
67
|
super.viewDidLoad()
|
68
68
|
}
|
69
69
|
}
|
70
|
-
```
|
70
|
+
```
|
71
|
+
|
72
|
+

|
73
|
+
|