One way to reset the MKMapView userTrackingMode when using SwiftUI is by creating a custom UIViewRepresentable for the MKMapView and implementing the updateUIView method:
struct MapView: UIViewRepresentable {
var mapView = MKMapView()
func makeUIView(context: Context) -> MKMapView {
mapView.showsUserLocation = true
return mapView
}
func updateUIView(_ uiView: MKMapView, context: Context) {
if uiView.userTrackingMode != .none {
uiView.setUserTrackingMode(.none, animated: true)
}
}
}
In this example, the updateUIView method checks if the current userTrackingMode is not .none
, and if so, it sets it to .none
to reset the user's tracking mode. The animated
parameter can be set to false
if you don't want the mode change to be animated.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-12 06:02:14 +0000
Seen: 32 times
Last updated: Jun 12 '23
What is the process to add a radio button with a check mark on a TableView cell using Swift?
Can you develop a "done" button for RxPickerViewAttributedStringAdapter?
When printing from WKWebView in Swift, the background is not taken into account.
How can one ensure that sub-classes have uniform method parameters in TypeScript?
How can the calculation of matrix determinant be performed using CUDA?
How can code repetition be prevented when using (box)plot functions?