質問編集履歴
2
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -166,6 +166,180 @@
|
|
166
166
|
|
167
167
|
|
168
168
|
|
169
|
+
### extensionをで分けた場合のコード
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
```ここに言語を入力
|
174
|
+
|
175
|
+
import UIKit
|
176
|
+
|
177
|
+
import MessageKit
|
178
|
+
|
179
|
+
import MessageInputBar
|
180
|
+
|
181
|
+
import InputBarAccessoryView
|
182
|
+
|
183
|
+
import FirebaseFirestore
|
184
|
+
|
185
|
+
import FirebaseAuth
|
186
|
+
|
187
|
+
import FirebaseStorage
|
188
|
+
|
189
|
+
import Nuke
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
struct Sender: SenderType{
|
194
|
+
|
195
|
+
var senderId: String
|
196
|
+
|
197
|
+
var displayName: String
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
struct MessageKitMessage: MessageType{
|
206
|
+
|
207
|
+
var sender: SenderType
|
208
|
+
|
209
|
+
var messageId: String
|
210
|
+
|
211
|
+
var sentDate: Date
|
212
|
+
|
213
|
+
var kind: MessageKind
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
class MessageKitChatViewController: MessagesViewController{
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
var senderUser = Auth.auth().currentUser!
|
226
|
+
|
227
|
+
var messages = [MessageType]()
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
let currentUser = Sender(senderId: Auth.auth().currentUser!.uid , displayName: Auth.auth().currentUser!.displayName ?? "Name not found")
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
override func viewDidLoad() {
|
240
|
+
|
241
|
+
super.viewDidLoad()
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
messagesCollectionView.messagesDataSource = self
|
246
|
+
|
247
|
+
messagesCollectionView.messagesLayoutDelegate = self
|
248
|
+
|
249
|
+
messagesCollectionView.messagesDisplayDelegate = self
|
250
|
+
|
251
|
+
messageInputBar.delegate = self
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
extension MessageKitChatViewController: MessagesDataSource{
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
func currentSender() -> SenderType {
|
272
|
+
|
273
|
+
return currentUser
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
func messageForItem(at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageType {
|
280
|
+
|
281
|
+
return messages[indexPath.section]
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
func numberOfSections(in messagesCollectionView: MessagesCollectionView) -> Int {
|
288
|
+
|
289
|
+
return messages.count
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
extension MessageKitChatViewController: MessagesLayoutDelegate{
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
extension MessageKitChatViewController: MessagesDisplayDelegate{
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
extension MessageKitChatViewController: MessageInputBarDelegate{
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String) {
|
330
|
+
|
331
|
+
print("button pressed")
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
```
|
340
|
+
|
341
|
+
|
342
|
+
|
169
343
|
### 試したこと
|
170
344
|
|
171
345
|
class MessageKitChatViewController: MessagesViewController, MessagesDataSource, MessagesLayoutDelegate, MessagesDisplayDelegate, MessageInputBarDelegateにInputBarAccessoryViewDelegateを追加したりしてみましたが上手くいきませんでした
|
1
タイトルをわかりやすく
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
送信ボタンを押したことが確認できません
|
1
|
+
【MessageKit】送信ボタンを押したことが確認できません
|
test
CHANGED
File without changes
|