質問編集履歴

1

tableviewの処理を追記

2016/12/28 12:07

投稿

tarofess
tarofess

スコア127

test CHANGED
File without changes
test CHANGED
@@ -51,3 +51,123 @@
51
51
  画面には他にもtextfieldがあり、textfieldがタップされた時にワケあって一つ前に表示されていたのtextfieldのキーボードを閉じたいのですが、どうすればキーボードを閉じることができるでしょうか?
52
52
 
53
53
  どなたかわかる方がいれば教えていただきたいです。よろしくお願いします。
54
+
55
+
56
+
57
+
58
+
59
+ ///追記///
60
+
61
+
62
+
63
+ ```swift
64
+
65
+ // MARK :- UITableViewDataSource
66
+
67
+
68
+
69
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
70
+
71
+ return self.displayCells().count
72
+
73
+ }
74
+
75
+
76
+
77
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
78
+
79
+ let id = displayCells()[indexPath.row].rawValue
80
+
81
+ let cell = tableView.dequeueReusableCell(withIdentifier: id, for: indexPath)
82
+
83
+ self.configureCell(targetCell: cell, indexPath: indexPath)
84
+
85
+
86
+
87
+ return cell
88
+
89
+ }
90
+
91
+
92
+
93
+ func configureCell(targetCell: UITableViewCell, indexPath: IndexPath) {
94
+
95
+ let type = displayCells()[indexPath.row]
96
+
97
+
98
+
99
+ switch type {
100
+
101
+ case .image:
102
+
103
+ guard let cell = targetCell as? SettingEditTableViewImageCell else {
104
+
105
+ return
106
+
107
+ }
108
+
109
+
110
+
111
+ if let image = SettingManager.sharedInstance.settings["image"]?.flatMap({$0}) {
112
+
113
+ if let imageString = image as? String {
114
+
115
+ cell.imageButton.setImage(Converter.sharedInstance.convertStringToImage(imageString: imageString), for: .normal)
116
+
117
+ }
118
+
119
+ } else {
120
+
121
+ cell.imageButton.setImage(UIImage(named: "camera"), for: .normal)
122
+
123
+ }
124
+
125
+
126
+
127
+ case .name:
128
+
129
+ if let name = SettingManager.sharedInstance.settings["name"]?.flatMap({$0}) {
130
+
131
+ if let cell = targetCell as? SettingEditTableViewTextCell {
132
+
133
+ cell.textField.text = name as? String
134
+
135
+ }
136
+
137
+ }
138
+
139
+
140
+
141
+ case .country:
142
+
143
+ if let country = SettingManager.sharedInstance.settings["country"]?.flatMap({$0}) {
144
+
145
+ if let cell = targetCell as? SettingEditTableViewCountryCell {
146
+
147
+ cell.countryTextField.text = country as? String
148
+
149
+ }
150
+
151
+ }
152
+
153
+
154
+
155
+ case .comment:
156
+
157
+ if let comment = SettingManager.sharedInstance.settings["comment"]?.flatMap({$0}) {
158
+
159
+ if let cell = targetCell as? SettingEditTableViewTextCell {
160
+
161
+ cell.textField.text = comment as? String
162
+
163
+ }
164
+
165
+ }
166
+
167
+ }
168
+
169
+ }
170
+
171
+
172
+
173
+ ```