1

So I want to use this thing to make my view scroll up when editing a TextField (it's a TabbedView App btw). However the animation didn't work unless I embedded it into a scroll view. This somehow broke my App.

So I get a Thread 1: EXC_BAD_ACCESS (code=1, address=0x8) in my AppDelegate now each time when I try to switch to another tab from the start of my App. I had a similar issue earlier where it I couldn't add my environmentObject() to my TabbedView directly but had to add it to the ContentView in the SceneDelegate. So this time my App works if I remove all my @State var for some reason.. can you see anything that is wrong with that?

struct Home: View {
    //@State var isSheetPresented = false //if this one isn't commented out it breaks my tabbed-view app
    @State var comment: String = "" //this one doesn't break everything?!?
    @EnvironmentObject var someStore: SomeStore //works fine as well

    var body: some View {
        NavigationView {
            ScrollView{ //This is THE ScrollView without everything else works (besides the animation)
                VStack(spacing: 20) {
                    Text("Hi!")
                }
            }
        }
    }
}

//--------------------

struct ContentView : View {
    @State private var selection = 0
    var body: some View {
        TabbedView(selection: $selection){
            Home()
                .tabItem{
                    Image(systemName: "house")
                    Text("Home")
            }
            .tag(0)
          Text("Tab # 2")
                .tabItem{
                    Image(systemName: "gear")
                    Text("#2")
            }
            .tag(1)
        }
    }
}

So yea, if you experienced sth. similar or have any idea what is going on please let me know....

thisIsTheFoxe
  • 1,584
  • 1
  • 9
  • 30

0 Answers0