質問編集履歴
2
新たな問題を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -113,3 +113,177 @@
|
|
113
113
|
self.navigationController?.pushViewController(groupsView, animated: true)
|
114
114
|
|
115
115
|
```
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
【新たな問題】
|
122
|
+
|
123
|
+
TouchUpイベントが複数回呼ばれてしまう。
|
124
|
+
|
125
|
+
addTagetの仕方が良くないのかなと思うのですが、どうすればよいかわかりません。。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```Swift
|
130
|
+
|
131
|
+
// MainViewCellInfo.swift
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
import Foundation
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
class MainViewCellInfo {
|
140
|
+
|
141
|
+
private(set) var projectName: String!
|
142
|
+
|
143
|
+
init(cellData cellData_: [String: AnyObject]){
|
144
|
+
|
145
|
+
projectName = cellData_["projectName"] as! String
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```Swift
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
// MainViewTableCell.swift
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
import UIKit
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
class MainViewTableCell: UITableViewCell{
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
@IBOutlet weak var projectNameLabel: UILabel!
|
172
|
+
|
173
|
+
@IBOutlet weak var Btn: UIButton!
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
class func nibName() -> String {
|
178
|
+
|
179
|
+
// クラス名と nib 名が同じ前提
|
180
|
+
|
181
|
+
return String(self)
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
class func cellId() -> String {
|
188
|
+
|
189
|
+
return String(self)
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
func setupWith(cellInfo cellInfo_: MainViewCellInfo) {
|
196
|
+
|
197
|
+
self.projectNameLabel.text = cellInfo_.projectName
|
198
|
+
|
199
|
+
//BtnにIDをセット
|
200
|
+
|
201
|
+
self.Btn.tag = cellInfo_.id
|
202
|
+
|
203
|
+
self.Btn.addTarget(MainViewController(), action: #selector(MainViewController.onMessageBtnClick(_:)), forControlEvents: .TouchUpInside)
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
```Swift
|
216
|
+
|
217
|
+
// MainViewController.swift
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
import UIKit
|
222
|
+
|
223
|
+
import Alamofire
|
224
|
+
|
225
|
+
import SwiftyJSON
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
class GroupsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource{
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
@IBOutlet weak var TableView: UITableView!
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
override func viewDidLoad() {
|
238
|
+
|
239
|
+
super.viewDidLoad()
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
self.TableView.delegate = self
|
244
|
+
|
245
|
+
self.TableView.dataSource = self
|
246
|
+
|
247
|
+
self.TableView?.rowHeight = 80.0
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
func tableView(TableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
256
|
+
|
257
|
+
print(jsonArray.count)
|
258
|
+
|
259
|
+
return jsonArray.count
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
func tableView(TableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
266
|
+
|
267
|
+
色々書いてます
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
func onMessageBtnClick(sender: UIButton) {
|
274
|
+
|
275
|
+
self.delegate._selectedProjectId = sender.tag
|
276
|
+
|
277
|
+
let storyboard = UIStoryboard(name: "Main", bundle: nil)
|
278
|
+
|
279
|
+
let nextVC = storyboard.instantiateViewControllerWithIdentifier("NextViewController")
|
280
|
+
|
281
|
+
self.navigationController?.pushViewController(nextVC, animated: true)
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
```
|
1
解決法を記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,3 +81,35 @@
|
|
81
81
|
IBOutletし直したり、名前を変えてみたりしましたが、うまくいきません。
|
82
82
|
|
83
83
|
よろしくお願いします。
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
【解決法】
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
元のコード
|
94
|
+
|
95
|
+
```Swift
|
96
|
+
|
97
|
+
let groupsView = GroupsViewController()
|
98
|
+
|
99
|
+
self.navigationController?.pushViewController(groupsView, animated: true)
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
修正後のコード
|
106
|
+
|
107
|
+
```Swift
|
108
|
+
|
109
|
+
let storyboard = UIStoryboard(name: "Main", bundle: nil)
|
110
|
+
|
111
|
+
let groupsView = storyboard.instantiateViewControllerWithIdentifier("GroupsViewController")
|
112
|
+
|
113
|
+
self.navigationController?.pushViewController(groupsView, animated: true)
|
114
|
+
|
115
|
+
```
|