JSQMessagesViewController 发送位置未加载



注意:这不是这个问题的副本:使用 JSQLocationMediaItem 发送位置

我已经尝试使用该页面上答案中的代码,结果没有改变。我的错误与该问题上显示的错误相同,但该问题的解决方案对我没有帮助。

这是我的代码:

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,它只是永远显示它。它从未实际加载地图。

我找到了这个问题的答案,通过将这个答案的代码 在JSQMessagesViewController 中显示位置媒体项目转换为 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)
})

最新更新