-
Notifications
You must be signed in to change notification settings - Fork 25
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
[Maybe a bug] call on onAppear() #12
Comments
Do you have a code sample of where your onAppear and what element it is on? |
import SwiftUI
import StatefulTabView
struct ContentView: View {
var body: some View {
StatefulTabView() {
Tab(title: "1", systemImageName: "map") {
Text("1")
}
Tab(title: "2", systemImageName: "map") {
Text("2").onAppear{
debugPrint("called")
}
}
Tab(title: "3", systemImageName: "map") {
Text("3")
}
Tab(title: "4", systemImageName: "map") {
Text("4")
}
}
}
} |
Does moving the on appear to the Tab element and not the Text element fix anything? If not I will try to debug today. |
I haven't tested it; my use-case is to use it inside the views. |
Seems to me like it might just be a difference in how SwiftUI lays out views on the different versions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure on which version is a bug (if it even is).
On iOS 13
onAppear()
gets called only once and never again. But, in iOS 14 it gets called on every show of the Tab.Tested on my device iOS 14.5 and multiple versions of the simulator: 13.0 - 14.0 - 14.5
The behaviour is consistent on all.
In my case, it helped solve the TabView issue on iOS 14. So I use this view only in this version, because I do want the onAppear call. So, thanks?
The text was updated successfully, but these errors were encountered: