mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
Fix LocationMessageCell reuse bug
This commit is contained in:
@@ -6,6 +6,11 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
|
||||
|
||||
## Upcoming release
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `LocationMessageCell` reuse bug, to avoid inconsistency when get capture image asynchronously.
|
||||
[#428](https://github.com/MessageKit/MessageKit/pull/428) by [@zhongwuzw](https://github.com/zhongwuzw).
|
||||
|
||||
## [[Prerelease] 0.12.0](https://github.com/MessageKit/MessageKit/releases/tag/0.12.0)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -34,6 +34,8 @@ open class LocationMessageCell: MessageCollectionViewCell {
|
||||
open var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray)
|
||||
|
||||
open var imageView = UIImageView()
|
||||
|
||||
private weak var snapShotter: MKMapSnapshotter?
|
||||
|
||||
open override func setupSubviews() {
|
||||
super.setupSubviews()
|
||||
@@ -47,6 +49,11 @@ open class LocationMessageCell: MessageCollectionViewCell {
|
||||
imageView.fillSuperview()
|
||||
activityIndicator.centerInSuperview()
|
||||
}
|
||||
|
||||
open override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
snapShotter?.cancel()
|
||||
}
|
||||
|
||||
open override func configure(with message: MessageType, at indexPath: IndexPath, and messagesCollectionView: MessagesCollectionView) {
|
||||
super.configure(with: message, at: indexPath, and: messagesCollectionView)
|
||||
@@ -67,6 +74,7 @@ open class LocationMessageCell: MessageCollectionViewCell {
|
||||
snapshotOptions.showsPointsOfInterest = options.showsPointsOfInterest
|
||||
|
||||
let snapShotter = MKMapSnapshotter(options: snapshotOptions)
|
||||
self.snapShotter = snapShotter
|
||||
snapShotter.start { (snapshot, error) in
|
||||
defer {
|
||||
self.activityIndicator.stopAnimating()
|
||||
|
||||
Reference in New Issue
Block a user