質問編集履歴

3

コードの追加

2018/08/10 13:51

投稿

pftyuk
pftyuk

スコア52

test CHANGED
File without changes
test CHANGED
@@ -38,24 +38,184 @@
38
38
 
39
39
  ```Swift
40
40
 
41
+ class AlarmViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
42
+
43
+ @IBOutlet weak var tableView: UITableView!
44
+
45
+
46
+
47
+ var cellItems = [ ["前日", "当日"]]
48
+
49
+
50
+
51
+ override func viewDidLoad() {
52
+
53
+ super.viewDidLoad()
54
+
55
+
56
+
57
+ tableView.delegate = self
58
+
59
+ tableView.dataSource = self
60
+
61
+
62
+
63
+ if let path: String = Bundle.main.path(forResource: "test", ofType: "json") {
64
+
65
+ let fileHandle : FileHandle = FileHandle(forReadingAtPath: path)!
66
+
67
+ let data : Data = fileHandle.readDataToEndOfFile()
68
+
69
+
70
+
71
+ do {
72
+
73
+ let json = try JSON(data: data)
74
+
75
+ let town = json["Town"][0]
76
+
77
+ let trashInfo = town["TrashInfo"]
78
+
79
+
80
+
81
+ var trashKindArray = [String]()
82
+
83
+ for (_,subJson):(String, JSON) in trashInfo {
84
+
85
+ for (key,_):(String, JSON) in subJson {
86
+
87
+ trashKindArray.append(key)
88
+
89
+ }
90
+
91
+ }
92
+
93
+ cellItems.append(trashKindArray)
94
+
95
+ } catch {
96
+
97
+ print("ファイルの内容取得時に失敗")
98
+
99
+ }
100
+
101
+ }else {
102
+
103
+ print("指定されたファイルが見つかりません")
104
+
105
+ }
106
+
107
+ }
108
+
109
+
110
+
111
+ override func didReceiveMemoryWarning() {
112
+
113
+ super.didReceiveMemoryWarning()
114
+
115
+ }
116
+
117
+
118
+
119
+ func numberOfSections(in tableView: UITableView) -> Int {
120
+
121
+ return cellItems.count
122
+
123
+ }
124
+
125
+
126
+
127
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
128
+
129
+ return cellItems[section].count
130
+
131
+ }
132
+
133
+
134
+
135
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
136
+
137
+ switch indexPath.section{
138
+
139
+ case 0:
140
+
141
+ let cell = tableView.dequeueReusableCell(withIdentifier: "AlarmTimeCell", for: indexPath) as! AlarmTableViewCell
142
+
143
+ cell.textLabel?.text = cellItems[indexPath.section][indexPath.row]
144
+
145
+ cell.timeLabel.text = "ここに時間を入れたい"
146
+
147
+
148
+
149
+ return cell
150
+
151
+ case 1:
152
+
153
+ let cell = tableView.dequeueReusableCell(withIdentifier: "AlarmSwitchCell", for: indexPath)
154
+
155
+ cell.textLabel?.text = cellItems[indexPath.section][indexPath.row]
156
+
157
+
158
+
159
+ if cell.accessoryView == nil {
160
+
161
+ cell.accessoryView = UISwitch()
162
+
163
+ }
164
+
165
+
166
+
167
+ return cell
168
+
169
+ default:
170
+
171
+ return tableView.dequeueReusableCell(withIdentifier: "AlarmTimeCell", for: indexPath)
172
+
173
+ }
174
+
175
+ }
176
+
177
+
178
+
41
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
179
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
42
180
 
43
181
  tableView.deselectRow(at: indexPath, animated: true)
44
182
 
45
-
46
-
47
- let datePicker = UIDatePicker()
48
-
49
- datePicker.datePickerMode = .time
50
-
51
-
52
-
53
- self.view.addSubview(datePicker)
54
-
55
- }
183
+ }
184
+
185
+ }
56
186
 
57
187
  ```
58
188
 
189
+ ```ここに言語を入力
190
+
191
+ class AlarmTableViewCell: UITableViewCell {
192
+
193
+ @IBOutlet weak var timeLabel: UILabel!
194
+
195
+
196
+
197
+ override func awakeFromNib() {
198
+
199
+ super.awakeFromNib()
200
+
201
+ }
202
+
203
+
204
+
205
+ override func setSelected(_ selected: Bool, animated: Bool) {
206
+
207
+ super.setSelected(selected, animated: animated)
208
+
209
+ }
210
+
211
+
212
+
213
+ }
214
+
215
+ ```
216
+
217
+
218
+
59
219
 
60
220
 
61
221
  ### イメージ画像

2

見出しの追加

2018/08/10 13:51

投稿

pftyuk
pftyuk

スコア52

test CHANGED
File without changes
test CHANGED
@@ -58,4 +58,6 @@
58
58
 
59
59
 
60
60
 
61
+ ### イメージ画像
62
+
61
63
  ![イメージ説明](878a0f458a1f0b514e3bca52bed6b75b.png)

1

画像の追加

2018/08/09 05:32

投稿

pftyuk
pftyuk

スコア52

test CHANGED
File without changes
test CHANGED
@@ -17,6 +17,12 @@
17
17
 
18
18
 
19
19
  どなたかご教示頂けると幸いです。
20
+
21
+
22
+
23
+ 追記
24
+
25
+ イメージの画像を追加しました
20
26
 
21
27
 
22
28
 
@@ -49,3 +55,7 @@
49
55
  }
50
56
 
51
57
  ```
58
+
59
+
60
+
61
+ ![イメージ説明](878a0f458a1f0b514e3bca52bed6b75b.png)