Hey, greay, did you ever find a solution for your problem? I'm having a similar problem with an app I'm working on where I have a one-and-done binding that functions as expected the first time, but then doesn't fire again upon changes. Any guidance would be greatly appreciated. :)
Post
Replies
Boosts
Views
Activity
Just for the record, I am experiencing this issue as well. I have a simple TabView:
import SwiftUI
struct HomeTabbedView: View {
var body: some View {
TabView {
RehearsalsView()
.tabItem {
Image(systemName: "calendar.circle.fill")
Text("Rehearsals")
}
ProfileWrapperView()
.tabItem {
Image(systemName: "person.crop.circle.fill")
Text("User Profile")
}
}
}
}
The ProfileWrapperView consists of the following:
import SwiftUI
struct ProfileWrapperView: View {
@EnvironmentObject var portal: Portal
@State var draftAdult: Adult = Adult.default
var body: some View {
if (portal.adult) != nil {
ProfileEditView(adult: $draftAdult)
.onAppear {
self.draftAdult = self.portal.adult!
print("ProfileEditView appearing")
}
.onDisappear {
self.portal.adult! = self.draftAdult
print("ProfileEditView disappearing")
}
} else {
Text("No adult data found.")
}
}
}
When the user switches tabs from the User Profile tab to the Rehearsals tab, the onDisappear handler is called (expected) immediately followed by the onAppear handler (unexpected). I'm looking into submitting a bug report now. (This will be my first time doing this, so wish me luck. :) If anyone has a workaround for this, please let me know.