質問編集履歴
2
詳細を記述
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
swiftで、TableViewに
|
1
|
+
swiftで、TableViewに罫線が表示されないため困っています。
|
test
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
解決したいこと
|
6
6
|
|
7
|
+
|
8
|
+
|
7
9
|
下記のコードでは、アプリに罫線が表示されずに困っています。
|
8
10
|
|
9
11
|
|
@@ -198,160 +200,4 @@
|
|
198
200
|
|
199
201
|
|
200
202
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
class ViewController: UIViewController, UITableViewDataSource {
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
//tableViewを参照できるようにする
|
210
|
-
|
211
|
-
@IBOutlet weak var tableView: UITableView!
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
//Insert below the tableView IBOutlet
|
216
|
-
|
217
|
-
var names = [String]()
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
//ユーザーのアクションとプログラムを結びつける
|
222
|
-
|
223
|
-
@IBAction func addName(sender: AnyObject) {
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
let alert = UIAlertController(title: "New Name",
|
228
|
-
|
229
|
-
message: "Add a new name",
|
230
|
-
|
231
|
-
preferredStyle: .Alert)
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
let saveAction = UIAlertAction(title: "Save",
|
236
|
-
|
237
|
-
style: .Default,
|
238
|
-
|
239
|
-
handler: { (action:UIAlertAction) -> Void in
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
let textField = alert.textFields!.first
|
244
|
-
|
245
|
-
self.names.append(textField!.text!)
|
246
|
-
|
247
|
-
self.tableView.reloadData()
|
248
|
-
|
249
|
-
})
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
let cancelAction = UIAlertAction(title: "Cancel",
|
254
|
-
|
255
|
-
style: .Default) { (action: UIAlertAction) -> Void in
|
256
|
-
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
alert.addTextFieldWithConfigurationHandler {
|
262
|
-
|
263
|
-
(textField: UITextField) -> Void in
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
alert.addAction(saveAction)
|
270
|
-
|
271
|
-
alert.addAction(cancelAction)
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
presentViewController(alert,
|
276
|
-
|
277
|
-
animated: true,
|
278
|
-
|
279
|
-
completion: nil)
|
280
|
-
|
281
|
-
}
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
//タイトルの設定とCellを毎回再利用する
|
286
|
-
|
287
|
-
override func viewDidLoad() {
|
288
|
-
|
289
|
-
super.viewDidLoad()
|
290
|
-
|
291
|
-
title = "\"The List\""
|
292
|
-
|
293
|
-
tableView.registerClass(UITableViewCell.self,
|
294
|
-
|
295
|
-
forCellReuseIdentifier: "Cell")
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
//テーブルの中のセクションの数を決める
|
304
|
-
|
305
|
-
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
306
|
-
|
307
|
-
return 1
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
//UITableViewのData Sourceを決める 変数namesの数を返す。
|
314
|
-
|
315
|
-
//変数cellに再利用するCellを入れて、Cellに入力された値をnamesに入れて返す。
|
316
|
-
|
317
|
-
func tableView(tableView: UITableView,
|
318
|
-
|
319
|
-
numberOfRowsInSection section: Int) -> Int {
|
320
|
-
|
321
|
-
return names.count
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
func tableView(tableView: UITableView,
|
328
|
-
|
329
|
-
cellForRowAtIndexPath
|
330
|
-
|
331
|
-
indexPath: NSIndexPath) -> UITableViewCell {
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
let cell =
|
336
|
-
|
337
|
-
tableView.dequeueReusableCellWithIdentifier("Cell")
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
cell!.textLabel!.text = names[indexPath.row]
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
return cell!
|
346
|
-
|
347
|
-
}
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
|
356
|
-
|
357
203
|
```
|
1
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
解決したいこと
|
6
|
+
|
5
|
-
下記のコードでは、アプリ
|
7
|
+
下記のコードでは、アプリに罫線が表示されずに困っています。
|
6
8
|
|
7
9
|
|
8
10
|
|
@@ -10,7 +12,9 @@
|
|
10
12
|
|
11
13
|
|
12
14
|
|
15
|
+
|
16
|
+
|
13
|
-
|
17
|
+
理想図
|
14
18
|
|
15
19
|
|
16
20
|
|
@@ -344,11 +348,7 @@
|
|
344
348
|
|
345
349
|
|
346
350
|
|
347
|
-
|
351
|
+
|
348
|
-
|
349
|
-
super.didReceiveMemoryWarning()
|
350
|
-
|
351
|
-
}
|
352
352
|
|
353
353
|
}
|
354
354
|
|