回答編集履歴

3

修正

2016/06/10 04:05

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -12,11 +12,15 @@
12
12
 
13
13
  class TopViewController: UIViewController {
14
14
 
15
-
15
+
16
16
 
17
17
  @IBAction func pushNext(sender: UIButton) {
18
18
 
19
- self.performSegueWithIdentifier("list", sender: nil)
19
+ if let listView = self.storyboard?.instantiateViewControllerWithIdentifier("list") as? ListViewController {
20
+
21
+ self.navigationController?.pushViewController(listView, animated: true)
22
+
23
+ }
20
24
 
21
25
  }
22
26
 
@@ -32,29 +36,7 @@
32
36
 
33
37
  @IBAction func pushModal(sender: UIButton) {
34
38
 
35
- self.performSegueWithIdentifier("modal", sender: nil)
36
-
37
- }
38
-
39
-
40
-
41
- override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
42
-
43
- if let modalView = segue.destinationViewController as? ModalViewController {
39
+ if let modalView = self.storyboard?.instantiateViewControllerWithIdentifier("modal") as? ModalViewController {
44
-
45
- modalView.listView = self
46
-
47
- }
48
-
49
- }
50
-
51
-
52
-
53
- func modalClose(modalView: ModalViewController) {
54
-
55
- // ModalViewControllerを閉じる
56
-
57
- modalView.dismissViewControllerAnimated(true) {
58
40
 
59
41
 
60
42
 
@@ -62,9 +44,9 @@
62
44
 
63
45
  let detilView = self.storyboard?.instantiateViewControllerWithIdentifier("detail") as? DetailViewController,
64
46
 
65
- let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController else {
47
+ let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController else {
66
48
 
67
- return
49
+ return
68
50
 
69
51
  }
70
52
 
@@ -74,7 +56,15 @@
74
56
 
75
57
  history.append(editView)
76
58
 
59
+ modalView.editView = editView
60
+
61
+
62
+
63
+ self.presentViewController(modalView, animated: true) {
64
+
77
- self.navigationController?.setViewControllers(history, animated: true)
65
+ self.navigationController?.setViewControllers(history, animated: false)
66
+
67
+ }
78
68
 
79
69
  }
80
70
 
@@ -90,7 +80,7 @@
90
80
 
91
81
 
92
82
 
93
- weak var listView: ListViewController!
83
+ weak var editView: EditiewController!
94
84
 
95
85
 
96
86
 
@@ -98,7 +88,7 @@
98
88
 
99
89
  // 親のViewControllerからModalを閉じる
100
90
 
101
- listView?.modalClose(self)
91
+ editView?.modalClose(self)
102
92
 
103
93
  }
104
94
 
@@ -114,7 +104,11 @@
114
104
 
115
105
  @IBAction func pushNext(sender: UIButton) {
116
106
 
117
- self.performSegueWithIdentifier("edit", sender: nil)
107
+ if let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController {
108
+
109
+ self.navigationController?.pushViewController(editView, animated: true)
110
+
111
+ }
118
112
 
119
113
  }
120
114
 
@@ -128,9 +122,13 @@
128
122
 
129
123
 
130
124
 
131
- override func viewDidLoad() {
125
+ var modalView: ModalViewController!
132
126
 
127
+
128
+
133
- super.viewDidLoad()
129
+ func modalClose(modalView: ModalViewController) {
130
+
131
+ modalView.dismissViewControllerAnimated(true, completion: nil)
134
132
 
135
133
  }
136
134
 

2

修正

2016/06/10 04:05

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -56,25 +56,25 @@
56
56
 
57
57
  modalView.dismissViewControllerAnimated(true) {
58
58
 
59
+
60
+
59
- var history = self.navigationController?.viewControllers
61
+ guard var history = self.navigationController?.viewControllers,
62
+
63
+ let detilView = self.storyboard?.instantiateViewControllerWithIdentifier("detail") as? DetailViewController,
64
+
65
+ let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController else {
66
+
67
+ return
68
+
69
+ }
60
70
 
61
71
 
62
72
 
63
- if let detilView = self.storyboard?.instantiateViewControllerWithIdentifier("detail") as? DetailViewController {
73
+ history.append(detilView)
64
74
 
65
- history?.append(detilView)
75
+ history.append(editView)
66
76
 
67
-
68
-
69
- if let editView = self.storyboard?.instantiateViewControllerWithIdentifier("edit") as? EditiewController {
70
-
71
- history?.append(editView)
72
-
73
- self.navigationController?.setViewControllers(history!, animated: true)
77
+ self.navigationController?.setViewControllers(history, animated: true)
74
-
75
- }
76
-
77
- }
78
78
 
79
79
  }
80
80
 

1

修正

2016/06/09 21:30

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -137,3 +137,11 @@
137
137
  }
138
138
 
139
139
  ```
140
+
141
+
142
+
143
+ ![image](29569c27514800450484ce3762195d5a.png)
144
+
145
+
146
+
147
+