質問編集履歴
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
let iconColors = ["FF0000", "00E676", "3E96FD", "FF8157"]
|
15
15
|
|
16
16
|
cell.colorIcon.backgroundColor = UIColor(hex: iconColors[indexPath.row])
|
17
|
+
|
18
|
+
return cell
|
17
19
|
}
|
18
20
|
|
19
21
|
// MARK: - Action
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,13 +8,43 @@
|
|
8
8
|
### 該当のソースコード
|
9
9
|
|
10
10
|
```swift
|
11
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
12
|
+
|
13
|
+
// 省略
|
11
14
|
let iconColors = ["FF0000", "00E676", "3E96FD", "FF8157"]
|
12
15
|
|
13
16
|
cell.colorIcon.backgroundColor = UIColor(hex: iconColors[indexPath.row])
|
17
|
+
}
|
18
|
+
|
19
|
+
// MARK: - Action
|
20
|
+
@IBAction func AddButton(_ sender: Any) {
|
21
|
+
|
22
|
+
var uiTextField = UITextField()
|
23
|
+
let ac = UIAlertController(title: "データ", message: "", preferredStyle: .alert)
|
24
|
+
let aa = UIAlertAction(title: "OK", style: .default) { (action) in
|
25
|
+
|
26
|
+
if uiTextField.text == "" {return}
|
27
|
+
|
28
|
+
// 配列に追加
|
29
|
+
self.textFieldStringList.append(uiTextField.text!)
|
30
|
+
// テーブル更新
|
31
|
+
self.tableView.reloadData()
|
32
|
+
// UserDefaultsに保存
|
33
|
+
UserDefaults.standard.set(self.textFieldStringList, forKey: "StringList")
|
34
|
+
print(uiTextField.text!)
|
35
|
+
}
|
36
|
+
ac.addTextField { (textField) in
|
37
|
+
textField.placeholder = "入力してください"
|
38
|
+
uiTextField = textField
|
39
|
+
}
|
40
|
+
ac.addAction(aa)
|
41
|
+
present(ac, animated: true, completion: nil)
|
42
|
+
}
|
14
43
|
```
|
15
44
|
|
16
45
|
### 発生している問題・エラーメッセージ
|
17
46
|
|
47
|
+
ボタンを押下するとエラーで落ちます。
|
18
48
|
```
|
19
49
|
Fatal error: Index out of range
|
20
50
|
致命的なエラー:インデックスが範囲外です
|
@@ -34,5 +64,5 @@
|
|
34
64
|
|
35
65
|
```
|
36
66
|
|
37
|
-
cellの背景色
|
67
|
+
cellの背景色をカラフルにする方法が知りたいです
|
38
68
|
よろしくお願いします
|