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

[Maybe a bug] call on onAppear() #12

Closed
fxsalazar opened this issue May 1, 2021 · 5 comments
Closed

[Maybe a bug] call on onAppear() #12

fxsalazar opened this issue May 1, 2021 · 5 comments

Comments

@fxsalazar
Copy link

fxsalazar commented May 1, 2021

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?

@NicholasBellucci
Copy link
Owner

Do you have a code sample of where your onAppear and what element it is on?

@fxsalazar
Copy link
Author

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")
        }
      }
    }
}

@NicholasBellucci
Copy link
Owner

Does moving the on appear to the Tab element and not the Text element fix anything? If not I will try to debug today.

@fxsalazar
Copy link
Author

I haven't tested it; my use-case is to use it inside the views.

@NicholasBellucci
Copy link
Owner

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants