[英]Having issues with navigation view (SwiftUI, iOS)
Code below:下面的代码:
NavigationView{
ZStack{
Color("SmokyBlack").ignoresSafeArea()
VStack{
//ModularContent(titleName: titleName, subtitleText: subtitleText, imageName: imageName)
NavigationLink(destination: SecondOnboardingView()){
OnboardingButton(buttonText: btnName, updateOnboarding: false)
}
}
}// parent vstack
.preferredColorScheme(/*@START_MENU_TOKEN@*/.dark/*@END_MENU_TOKEN@*/)
.navigationBarHidden(true)
} //nav view ends
My Issue: https://imgur.com/a/ALBdEBs我的问题: https://imgur.com/a/ALBdEBs
The button is clearly being pressed but nothing is happening该按钮显然被按下,但没有发生任何事情
edit: code for the button.编辑:按钮的代码。 I have tried changing this button to plain text but it still doesn't work.
我已经尝试将此按钮更改为纯文本,但它仍然不起作用。
struct OnboardingButton: View {
var buttonText: String
var updateOnboarding: Bool
@AppStorage("onboardingCheck") var onboardingCheck: Bool?
var body: some View {
Button(action: {onboardingCheck=updateOnboarding},
label: {
ZStack{
RoundedRectangle(cornerRadius: 5)
.foregroundColor(.white)
.frame(width: 300, height: 60, alignment: .center)
Text(buttonText)
.foregroundColor(.black)
.font(.system(size: 20))
.fontWeight(.semibold)
}
})
}
}
I seem to have figured out why.我似乎明白了原因。
Button(action: {onboardingCheck=updateOnboarding},
from OnboardingButton seems to only accept true as an answer to continue. To work around this, I simply made a different file that does not use Button() but instead the following: Button(action: {onboardingCheck=updateOnboarding},
from OnboardingButton 似乎只接受 true 作为继续的答案。为了解决这个问题,我只是制作了一个不使用 Button() 而是使用以下内容的不同文件:
struct OnboardingButtonTwo: View {
var buttonText: String
var body: some View {
ZStack{
RoundedRectangle(cornerRadius: 5)
.foregroundColor(.white)
.frame(width: 300, height: 60, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
Text(buttonText)
.foregroundColor(.black)
.font(.system(size: 20))
.fontWeight(.semibold)
}
.padding(.bottom, 10)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.