I have a tricky use case with vertical TabView in SwiftUI on watchOS. I display a Map in a Tabview with a button to toggle interaction with the map using Digital Crown to zoom/pan. If I have no interaction with the map, I can move from one tab to another using Digital Crown. If I set interaction to the map for using Digital Crown and then remove it, I can't use the Digital Crown anymore to change the active TabView. I can only do that by a swipe gesture on the screen. I have tried different methods to force focus back to the TabView controller without any success. Do you have any tip or suggestion ?
Here is the sample code:
import SwiftUI
import MapKit
struct ContentView: View {
@State private var isZooming = false
var body: some View {
TabView {
// Tab 1
VStack {
Text("First tab")
}
// Tab 2
VStack {
Map(interactionModes: isZooming ? .zoom : [])
Button {
isZooming.toggle()
} label: {
Text(isZooming ? "Cancel" : "Zoom")
}
}
}
.tabViewStyle(.verticalPage)
}
}
Apple has acknowledged it’s a bug. The workaround is to set the Map to disabled by adding the following view modifier in this sample case :
.disabled(isZooming)