Swift JSQMessagesViewController发送位置未加载
注意:这不是该问题的副本: 我已经尝试过使用该页面答案中的代码,结果没有改变。我的错误与该问题上显示的错误相同,但该问题的解决方案对我没有帮助 这是我的密码:Swift JSQMessagesViewController发送位置未加载,swift,jsqmessagesviewcontroller,Swift,Jsqmessagesviewcontroller,注意:这不是该问题的副本: 我已经尝试过使用该页面答案中的代码,结果没有改变。我的错误与该问题上显示的错误相同,但该问题的解决方案对我没有帮助 这是我的密码: let loc: JSQLocationMediaItem = JSQLocationMediaItem() // Assume that cllocation is a proppert location. // I have already confirmed this by printing cllocation.location
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()
})
<> P>发生的是,我的聊天气泡好像是在接收,但是中间有一个<代码> uiActuviyDeaCurraveValue/Cuth>,它只显示了永远。它从未实际加载地图。我通过将此答案中的代码转换为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)
})
您可能还希望保留对JSQLocationMediaItem的引用。