The example hangs
zhouhao27 opened this issue · comments
When I ran the app for MapKit Example, it hangs when I zoom in/zoom out or pan the screen.
I think it's caused by this:
let snapshots: [UIView] = toRemove.flatMap { annotation in
guard let annotationView = mapView.view(for: annotation),
let snapshot = annotationView.snapshotView(afterScreenUpdates: false),
mapView.frame.intersects(annotationView.frame) == true else {
return nil
}
snapshot.frame = annotationView.frame
mapView.insertSubview(snapshot, aboveSubview: annotationView)
return snapshot
}
UIView.animate(withDuration: 0.2, animations: {
for snapshot in snapshots {
snapshot.transform = CGAffineTransform(scaleX: 0.01, y: 0.01)
snapshot.layer.opacity = 0
}
},
completion: { _ in
for snapshot in snapshots {
snapshot.removeFromSuperview()
}
})
After I removed these lines, everything is ok.