我正在尝试使用 Apple 的SwiftUI制作一个应用程序,我需要有两个按钮在List一行中显示两个不同的视图。
我使用Xcode beta 7和MacOS Catalina beta 7。我试图添加一个Button呈现视图但是,我无法点击它,当我尝试在一个简单的Button外部List并点击它时,该AddList()视图没有出现。我也试过添加一个navigationButton内部,navigationButton但它也不起作用。tapAction单击它时添加一个也不起作用,视图仍然没有出现
NavigationView {
List(0..<5) { item in
NavigationLink(destination: ContentOfList()) {
Text("hello") // dummy text
Spacer()
Text("edit")
.tapAction {
AddList() // This is the view I want to present
}
}
}.navigationBarItems(trailing: NavigationLink(destination: AddList(), label: { // doesn't work within navigationBarItems
Image(systemName: "plus.circle.fill")
}))
}
Run Code Online (Sandbox Code Playgroud)
我希望AddList()视图出现,但在这两种情况下,它没有。
我正在尝试创建一个应用程序,当用户不知道时,它会显示一个会更改每个级别的文本。目标是说出一个显示的句子(是的,它是为孩子们设计的):
\n\n@IBAction func dontknow(_ sender: Any) {\n let utterance = AVSpeechUtterance(string: textLabel.text)\n utterance.voice = AVSpeechSynthesisVoice(language: "fr-FR")\n utterance.rate = 0.4\n\n let synthesizer = AVSpeechSynthesizer()\n synthesizer.speak(utterance)\n\n}\nRun Code Online (Sandbox Code Playgroud)\n\n该应用程序的构造如下:\n如果用户不知道 -> 他可以单击按钮说出文本\n如果他是对的 -> 他进入下一个级别。
\n\n当他第一次输入要说的按钮时,应用程序会说一些话,但是当用户尝试说出文本并且在下一个级别时,他单击要说的按钮,则什么也没有发生。它只是抛出这个错误:Failure starting audio queue \xe2\x89\xa5\xcb\x9a\xcb\x9b\xcb\x87
完整代码:
\n\nimport UIKit\nimport AVFoundation\nimport Speech\n\nclass ReadViewController: UIViewController, SFSpeechRecognizerDelegate {\n var texts = ["Je mange des p\xc3\xa2tes", "Bonjour Jean comment vas-tu", "Qui est-ce", "J\'en ai marre", "Je ne te trouve pas gentil", "Pourquoi tu ne veux pas","Tu es si gentil", "Tu …Run Code Online (Sandbox Code Playgroud) speech-recognition avfoundation ios swift sfspeechrecognizer