I'm writing my own SideBar which utilises the TabView function to call on different views when the corresponding title in SideBar is tapped.
This works pretty well. However, I've noticed that there seems to be an invisible TabBar on the bottom of the screen. It's not visible, but when I tested on my iPhone 12 Pro, if you give it enough taps, the screen will change to different views depending on which invisible TabBar you tap.
I've tried implementing the .toolbar(.hidden, for: .tabBar) line in the individual views but still encounter the same weird issue.
It seems like a bug to me but not sure what's the workaround for this?
import SwiftUI
struct MainTabView: View {
@State var isSideBarOpened = false
@State var selectedSideBar = 0
var body: some View {
ZStack{
TabView(selection: $selectedSideBar) {
DashboardView(isSideBarOpened: $isSideBarOpened)
.tag(0)
.toolbar(.hidden, for: .tabBar)
FoodDBView(isSideBarOpened: $isSideBarOpened)
.tag(1)
.toolbar(.hidden, for: .tabBar)
MedDBView(isSideBarOpened: $isSideBarOpened)
.tag(2)
.toolbar(.hidden, for: .tabBar)
ProfileView(isSideBarOpened: $isSideBarOpened)
.tag(3)
.toolbar(.hidden, for: .tabBar)
}
SideBar(selectedSideBar: $selectedSideBar, isShowing: $isSideBarOpened)
}
}
}
I thought when the toolbar is hidden, when you tap on the bottom of the screen (where the tabbar should be), nothing should happen. But it is not the case. It doesn't happen on the first tap, but if you continuously tap it for like 50 times, the screen just changes to different views.