Post

Replies

Boosts

Views

Created

Prevent clusters from continuously reorganizing when using MKMapView with SwiftUI
We've got some areas of dense annotations/clusters on our map, but when the user is zoomed all the way in, the clusters spend several seconds reorganizing, even after the user has tapped one. This was not a problem when we were using MKMapView without SwiftUI, so the issue might be related to Views updating. I'm trying to give clusters and their member annotations a similar clusteringIdentifier when zoomed all the way in, but that causes the exception: MKAnnotationView instances for cluster annotations cannot use a different clusteringIdentifier than its annotation. I've tried a few variations of this: func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { ... if let cluster = annotation as? MKClusterAnnotation { let id = UUID().uuidString     mapView.view(for: annotation)?.clusteringIdentifier = id view = ClusterAnnotationView(annotation: annotation, reuseIdentifier: identifier)     view.clusteringIdentifier = id      for anno in cluster.memberAnnotations {          if mapView.annotations.contains(where: { anno === $0 }) {                 mapView.view(for: anno)?.clusteringIdentifier = id             }         } } } Any advice on getting clusters to stop reorganizing while not zooming in or out would be appreciated.
0
1
1.1k
Jun ’21
Image classification works in preview, but not simulator
Following the guide found here, I've been able to preview image classification in Create ML and Xcode. However, when I swap out the MobileNet model for my own and try running it as an app, images are not classified accurately. When I check the same images using my model in its Xcode preview tab, the guesses are accurate. I've tried changing this line to the different available options, but it doesn't seem to help: imageClassificationRequest.imageCropAndScaleOption = .centerCrop Does anyone know why a model would work well in preview but not while running in the app? Thanks in advance.
1
1
1.7k
Apr ’22