JSQMessagesViewController 发送位置未加载
JSQMessagesViewController sending location not loading
注意:这不是这个问题的副本:
我已经尝试使用该页面上答案中的代码,结果没有改变。我的错误与该问题上显示的错误相同,但该问题的解决方案对我没有帮助。
这是我的代码:
let loc: JSQLocationMediaItem = JSQLocationMediaItem()
// Assume that cllocation is a proppert location.
// I have already confirmed this by printing cllocation.location to the console.
loc.setLocation(cllocation, withCompletionHandler: {
// This is a incoming message
loc.appliesMediaViewMaskAsOutgoing = false
// Adding the JSQMessage to my array. Assume that all information given is correct.
self.JSQMessages[self.JSQMessages.count - 1].append(JSQMessage(senderId: "2", senderDisplayName: self.chatWithUser.username, date: message.messageDate, media: loc))
self.collectionView.reloadData()
})
我的聊天气泡显示为正在接收,但中间有一个 UIActivityIndicatorView
,而且一直显示。它从未实际加载地图。
我找到了答案,方法是将代码从这个答案 转换为 swift。对于将来需要它的任何人,我的代码现在看起来像这样:
let loc: JSQLocationMediaItem = JSQLocationMediaItem()
loc.appliesMediaViewMaskAsOutgoing = false
self.JSQMessages[self.JSQMessages.count - 1].append(JSQMessage(senderId: "2", senderDisplayName: self.chatWithUser.username, date: message.messageDate, media: loc))
loc.setLocation(cllocation, withCompletionHandler: {
self.collectionView.reloadData()
self.scrollToBottom(animated: true)
})
注意:这不是这个问题的副本:
我已经尝试使用该页面上答案中的代码,结果没有改变。我的错误与该问题上显示的错误相同,但该问题的解决方案对我没有帮助。
这是我的代码:
let loc: JSQLocationMediaItem = JSQLocationMediaItem()
// Assume that cllocation is a proppert location.
// I have already confirmed this by printing cllocation.location to the console.
loc.setLocation(cllocation, withCompletionHandler: {
// This is a incoming message
loc.appliesMediaViewMaskAsOutgoing = false
// Adding the JSQMessage to my array. Assume that all information given is correct.
self.JSQMessages[self.JSQMessages.count - 1].append(JSQMessage(senderId: "2", senderDisplayName: self.chatWithUser.username, date: message.messageDate, media: loc))
self.collectionView.reloadData()
})
我的聊天气泡显示为正在接收,但中间有一个 UIActivityIndicatorView
,而且一直显示。它从未实际加载地图。
我找到了答案,方法是将代码从这个答案
let loc: JSQLocationMediaItem = JSQLocationMediaItem()
loc.appliesMediaViewMaskAsOutgoing = false
self.JSQMessages[self.JSQMessages.count - 1].append(JSQMessage(senderId: "2", senderDisplayName: self.chatWithUser.username, date: message.messageDate, media: loc))
loc.setLocation(cllocation, withCompletionHandler: {
self.collectionView.reloadData()
self.scrollToBottom(animated: true)
})