Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using @State variable to change which URL is loaded fails #27

Open
smaldd14 opened this issue Nov 3, 2021 · 1 comment
Open

using @State variable to change which URL is loaded fails #27

smaldd14 opened this issue Nov 3, 2021 · 1 comment

Comments

@smaldd14
Copy link

smaldd14 commented Nov 3, 2021

Hi,

I am using iOS 14.5 and am trying to render a different SafariView depending on which button is clicked. I change the URL on the button action, but I still see a fatal error that nil was unexpectedly found. Any idea what a fix is?
Here is how I was to render the .safariView

VStack {
List {
Button(action: {self.url = appTermsUrl; self.showSafari = true}) {
HStack {
Text("Terms of Service").font(.custom("HelveticaNeue", size: 18))
Image(systemName: "chevron.right")
}
}
Button(action: {self.url = appPrivacyPolicyUrl; self.showSafari = true}) {
HStack {
Text("Privacy Policy").font(.custom("HelveticaNeue", size: 18))
Image(systemName: "chevron.right")
}
}
Button(action: {self.url = appAboutUrl; self.showSafari = true}) {
HStack {
Text("About us").font(.custom("HelveticaNeue", size: 18))
Image(systemName: "chevron.right")
}
}

        }
    }.padding(.top)
        .safariView(isPresented: $showSafari) {
            SafariView(
                url: URL(string: url)!,
                configuration: SafariView.Configuration(
                    entersReaderIfAvailable: false,
                    barCollapsingEnabled: true
                )
            )
            .preferredBarAccentColor(.clear)
            .preferredControlAccentColor(.accentColor)
            .dismissButtonStyle(.done)
        }
@viere1234
Copy link

As I comment in Issues#33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants