I have a ContentView written in swiftUI as simple as below. ''' var body: some View {
NavigationView {
List {
Section {
PresentationLink(destination: Text("new Profile")) {
Text("new Profile")
}
}
}
}
'''
everything is good first time I tap on new profile but when I close the modal and try to tap again, it does not work. is it a bug or a feature?
PresentationLink has been deprecated in Xcode 11 beta 4 in favor of .sheet, which seems to solve the issue.
If you change the code to .sheet like below:
You will then be able to use the modal as many times as you like instead of just once.
EDIT: After implementing this in a real scenario, I've found that the underlying bug still seems to exist if you put
.sheet
inside of theList
. If you follow the code example above, you won't experience this issue but in a real scenario where you're using aList
, you're probably going to want information about the particular item that was selected passed in to the modal. In that case, you're going to need to pass information about the selection via a@State
var or some other means. Below is an example: