I have a TabView with nested views, and one of the views has a TextField. When I click on the TextField, the keyboard blocks the TextField. However, if I remove the .tabViewStyle(.page) from TabView, everything works as expected! I've attached a GIF below. Any help would be appreciated.
struct ContentView: View {
init() {
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(Color.red)
UIPageControl.appearance().pageIndicatorTintColor = UIColor.lightGray
UIPageControl.appearance().tintColor = UIColor.lightGray
}
var body: some View {
TabView{
anotherView()
TextView()
anotherView()
}
.edgesIgnoringSafeArea(.all)
.padding(.bottom, 20)
.frame(
width: UIScreen.main.bounds.width ,
height: UIScreen.main.bounds.height
)
.tabViewStyle(.page) // issue here but I need the page style
.indexViewStyle(.page(backgroundDisplayMode: .interactive))
}
}
struct TextView: View {
@State var textInput = ""
var body: some View {
VStack{
Spacer()
TextField("textfield", text: $textInput)
}
.padding()
}
}
[
]
If I remove the .tabViewStyle(.page) then it works. However I need the swipe feature and for the keyboard to not block the TextField
The issue was using TabView with the .page on it, what I did was add a modifier so that when the keyboard appears it moves the view up above the keyboard.