11

As the questions says I want to navigate to another view without NavigationButton, something like "pushView" and "popView" in UIkit

6
  • 1
    alternate you can use with PresentationButton Commented Jun 12, 2019 at 7:12
  • 1
    I don't think there's another way (yet) to push/pop views Commented Jun 12, 2019 at 7:15
  • PresentationButton is correct answer as @Anbu.Karthik said. Commented Jun 12, 2019 at 7:47
  • Why do you not want to use NavigationButton? Commented Jun 12, 2019 at 10:04
  • 2
    @Fogmeister Because I want to do a request to the server when the button is pressed and navigate to the next view after I get the response from the server, but I did not manage how to do that with a NavigationButton, only with Button :( Commented Jun 12, 2019 at 11:16

1 Answer 1

7

I consider this more like a work-around for a limitation, but it worked for me:

Add a boolean state variable which defines whether the link is active. E.g.:

@State private var showLinkTarget = false

Add an invisible NavigationLink like this:

NavigationLink(destination: LinkTargetView(), isActive: self.$showLinkTarget ) {
   Spacer().fixedSize() 
}
Sign up to request clarification or add additional context in comments.

3 Comments

The problem is that this logic only works once in my case
Alternatively use EmptyView instead of Spacer().fixedSize()
If it only works once, did you made sure that you set showLinkTarget to false again on return?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.