質問編集履歴

1

コードの変更

2018/06/24 11:45

投稿

s1209
s1209

スコア13

test CHANGED
File without changes
test CHANGED
@@ -346,116 +346,90 @@
346
346
 
347
347
 
348
348
 
349
- class SettingViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
349
+ class TableViewController: UITableViewController {
350
-
351
-
352
-
353
- @IBOutlet weak var tableView: UITableView!
350
+
354
-
355
-
351
+
356
352
 
357
353
  override func viewDidLoad() {
358
354
 
359
355
  super.viewDidLoad()
360
356
 
361
-
362
-
363
- tableView.delegate = self
357
+
364
-
365
- tableView.dataSource = self
358
+
366
-
359
+
360
+
367
- }
361
+ }
362
+
363
+
364
+
368
-
365
+ override func didReceiveMemoryWarning() {
366
+
369
-
367
+ super.didReceiveMemoryWarning()
368
+
370
-
369
+ }
370
+
371
+
372
+
373
+
374
+
371
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
375
+ override func numberOfSections(in tableView: UITableView) -> Int {
372
376
 
373
377
  return 1
374
378
 
375
379
  }
376
380
 
377
-
378
-
381
+
382
+
379
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
383
+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
380
-
381
-
382
-
383
- let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
384
+
384
-
385
- return cell
385
+ return 2
386
-
386
+
387
- }
387
+ }
388
+
389
+
390
+
388
-
391
+ ```
389
-
390
-
392
+
393
+
394
+
391
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
395
+ ```Swift
392
-
396
+
397
+
398
+
393
- return 50
399
+ import UIKit
400
+
401
+
402
+
394
-
403
+ class TableViewCell: UITableViewCell {
404
+
405
+
406
+
407
+ @IBOutlet weak var numberLabel: UILabel!
408
+
409
+ @IBOutlet weak var numberSwitch: UISwitch!
410
+
411
+
412
+
413
+ override func awakeFromNib() {
414
+
415
+ super.awakeFromNib()
416
+
395
- }
417
+ }
396
-
397
-
398
-
399
-
400
-
401
-
402
-
418
+
419
+
420
+
403
- @IBAction func saveButton(_ sender: UIButton) {
421
+ override func setSelected(_ selected: Bool, animated: Bool) {
404
-
405
-
406
-
422
+
407
- dismiss(animated: true) {}
423
+ super.setSelected(selected, animated: animated)
408
-
409
-
410
-
424
+
425
+
426
+
411
- }
427
+ }
412
-
413
-
428
+
429
+
414
430
 
415
431
  }
416
432
 
433
+
434
+
417
435
  ```
418
-
419
-
420
-
421
- ```Swift
422
-
423
-
424
-
425
- import UIKit
426
-
427
-
428
-
429
- class TableViewCell: UITableViewCell {
430
-
431
-
432
-
433
- @IBOutlet weak var numberLabel: UILabel!
434
-
435
- @IBOutlet weak var numberSwitch: UISwitch!
436
-
437
-
438
-
439
- override func awakeFromNib() {
440
-
441
- super.awakeFromNib()
442
-
443
- }
444
-
445
-
446
-
447
- override func setSelected(_ selected: Bool, animated: Bool) {
448
-
449
- super.setSelected(selected, animated: animated)
450
-
451
-
452
-
453
- }
454
-
455
-
456
-
457
- }
458
-
459
-
460
-
461
- ```