'Xcode simulator sporadically not responding to touch events - SwiftUI
Setup: a SwiftUI List with NavigationLinks wrapped in a NavigationView. Tapping on the NavigationLink opens DeviceInfoView only 50% of the time. Environment: Simulator 13.2, Xcode 13.2.1. All works fine on a real device. Any insights? Thanks.
struct DeviceSearchView: View {
@StateObject private var viewModel = DeviceSearchViewModel()
var body: some View {
NavigationView {
Group {
switch viewModel.searchResults {
// ...
case let .success(results):
List(results, id: \.imei) { res in
NavigationLink(destination: DeviceInfoView(imei: res.imei)) {
Text("IMEI: \(res.imei)")
}
}
.listStyle(.insetGrouped)
.navigationTitle("Title")
}
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
HStack {
Image(systemName: "cpu")
Text("...").font(.headline)
}
}
}
.searchable(text: $viewModel.searchText, prompt: "IMEI").keyboardType(.numberPad)
}
}
}
...and in the viewModel:
@MainActor
final class DeviceSearchViewModel: ObservableObject {
@Published var searchResults: AsyncResult<[FindySearchResult]> = .empty
// etc...
Solution 1:[1]
Simulator -> Device -> Erase all content and settings... fixed it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Peter |
