JSQMessagesViewController를 사용하여 내 앱에서 채팅을 구현하고 있습니다. 내 위치와 채팅하고있는 사용자를 보낼 수 있기를 원합니다. 이것이 내가 한 일이다.JSQLocationMediaItem을 사용하여 위치 보내기
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
self.latestLocation = locations[locations.count-1]
}
let sendLocation = UIAlertAction(title: "Send Location", style: .default, handler: { (action) -> Void in
let loc: JSQLocationMediaItem = JSQLocationMediaItem(location: self.latestLocation)
loc.appliesMediaViewMaskAsOutgoing = true
let locmessage: JSQMessage = JSQMessage(senderId: self.senderId, senderDisplayName: self.senderDisplayName, date: NSDate() as Date!, media: loc)
self.messages.append(locmessage)
self.finishSendingMessage(animated: true)
self.collectionView.reloadData()
print("Location button tapped")
})
let cancelButton = UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
print("Cancel button tapped")
})
alertController.addAction(sendLocation)
self.navigationController!.present(alertController, animated: true, completion: nil)
그러나 보내기 위치 버튼을 클릭하면 방금 바퀴가 달린 이미지 풍선이 나타나 영원히 계속됩니다.
이 코드를 사용하려고하는데 정확히 무엇입니까? self.latestLocation = locations [locations.count-1] 설명 할 수 있습니까? –