AttributeGraph: cycle detected / Modifying state during view update

In a word, the keyboard need to be closed first, before you want to make some page changes. Refer to StackOverFlow struct ContentView: View { @State var isDisabled = false @State var text = "" var body: some View { VStack { TextField("", text: $text) .textFieldStyle(.roundedBorder) .disabled(isDisabled) Button("Disable text field") { closeKeyboard() isDisabled = true } } } func closeKeyboard() { UIApplication.shared.sendAction( #selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil ) } }

Create ML Model predicts multiple results

import CoreML import NaturalLanguage struct ModelTool { private static var defaultModelClassifier: ModelClassifier { do { return try ModelClassifier(configuration: .init()) } catch { fatalError("Couldn't load ModelClassifier due to: \(error.localizedDescription)") } } static func predictLabelFor(_ value: String) -> [String]? { let rawModel = defaultModelClassifier.model var nlModel:NLModel? = try? NLModel(mlModel: rawModel) // it will return 11 results let rawResults: [String : Double]? = nlModel?.predictedLabelHypotheses(for: value, maximumCount: 11) // return the key list and sorted by precision return rawResults?

CoreML Code=0 Prediction failed

Create ML model prediction failed when the model file was replaced. Check the file access, make the access: everyone read & write: Right-click on the file, find the Detail, change the read & write access to everyone. And only when the app Minimum Deployments and Simulator vision are both 17.0, you can test the prediction in the simulator(I think it’s a bug, and Canvas never work).

sheet style abnormal when in stack

HStack { Button("Test"){ flag = true }.sheet(isPresented: $flag){ NewPage() .presentationDetents([.medium, .large]) .presentationBackgroundInteraction(.automatic) .presentationBackground(.regularMaterial) } There will be strange changes of the style in the sheet, just change the position of .sheet modifier from Button to HStack: HStack { Button("Test"){ flag = true } }.sheet(isPresented: $flag){ NewPage() .presentationDetents([.medium, .large]) .presentationBackgroundInteraction(.automatic) .presentationBackground(.regularMaterial)