Interaction with an input field in a view inside my TabView, is causing my other views to animate weirdly when they appear. In addition, the nav bar doesn't hide as it should.
I've established it is an input field + TabView problem because:
I've looked into a few solutions but had no luck: Is there a way to override the keyboard animation? Is there a way to force the tab view views to "appear" when the tab view loads? Is there a way to stop other TabView sub views being impacted by changes in other TabView views
Tab iew Code
TabView (){
ViewA()
.tabItem {
Image("viewa").renderingMode(.template)
Text("viewa")
}
ViewB()
.tabItem {
Image("viewb").renderingMode(.template)
Text("viewb")
}
ViewC()
.tabItem {
Image("viewc").renderingMode(.template)
Text("viewc")
}
ViewD()
.tabItem {
Image("viewd").renderingMode(.template)
Text("viewd")
}
}
In the tab views child views, animation is applied to a VStack containing my items like so.
VStack{
items...
}.animation(.easeInOut)
This code is used to hide the nav:
.background(NavigationConfigurator { nav in
nav.hidesBarsOnSwipe = true
})
Expected behaviour:
Behaviour when interacting with an input field:
It appears this is an ongoing bug with TabView and the keyboard. The temporary fix until this is resolved is converting the VStacks to LazyVStacks so that the views do not load until necessary.
See: OnAppear calls unexpectedly when Keyboard Appears in SwiftUI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With