如何解决按钮未点击
使用SwiftUI。由于某些非常奇怪的原因,此按钮不可单击(它出现但不执行其动作任务)。当我将Button放在HStack外面时,它突然工作了。我是愚蠢的还是它的错误。谢谢!
ZStack{
Image("Background")
.resizable()
.edgesIgnoringSafeArea([.top,.bottom])
vstack{
HStack{
Text("Dari Learner")
.font(.largeTitle)
.foregroundColor(Color.white)
.padding(.top,50)
.padding(.leading,90)
Button(action: {
print("Button Tapped")
self.viewmodel.createQuiz()
}) {
Text("Next")
.background(Color.green.opacity(0.5))
.cornerRadius(25)
.opacity(self.dim ? 1 : 0)
.transition(.scale)
.animation(.easeInOut(duration: 1.5))
}// !disabled because this is also used for the answerbubbles
}
ZStack{
AnswerBubble(fillColor: Color.black,isChosen: false)
Text(viewmodel.getActualAnswer().word.DariWord)
}
Grid(viewmodel.answers) { answer in
QuizView(answer: answer,fillColor: self.colorFor(answer: answer,correctAnswer: self.viewmodel.getActualAnswer())).onTapGesture {
self.tappedAnswers.append(answer)
if self.viewmodel.chooseAnswer(answer: answer){
self.dim.toggle()
self.disabled.toggle()
}
}
.animation(.easeInOut(duration: 1.0))
.disabled(self.disabled)
}
}
.edgesIgnoringSafeArea([.top])
}.ondisappear{
self.viewmodel.createQuiz()
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。