我使用以下代码发送带有位置的 JSQMessage,我没有任何错误,但消息未显示在视图中。
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
var latestLocation: CLLocation = locations[locations.count-1]
let loc: JSQLocationMediaItem = JSQLocationMediaItem(location: latestLocation)
loc.appliesMediaViewMaskAsOutgoing = true
let locmessage: JSQMessage = JSQMessage(senderId: self.senderId, senderDisplayName: self.senderDisplayName, date: NSDate(), media: loc)
messages.append(locmessage)
self.finishSendingMessageAnimated(true)
}
和
override func collectionView(collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageBubbleImageDataSource! {
let factory = JSQMessagesBubbleImageFactory()
if messages[indexPath.row].senderId == senderId {
return factory.outgoingMessagesBubbleImageWithColor(UIColor.lightGrayColor())
} else {
return factory.incomingMessagesBubbleImageWithColor(UIColor.greenColor())
}
}
其他类型的消息(照片和视频)没有问题。
谁能帮我。
谢谢你。