If you set the frame width on the tabview, the page will not change on rotation. I use the maximum of the screen width and height as the tabview frame width, and that seems to work well.
struct ContentView: View {
@State var currentPage: Int = 1
var body: some View {
ZStack {
TabView(selection: $currentPage) {
Text("1").tag(0)
Text("2").tag(1)
Text("3").tag(2)
}
.frame(width: max(UIScreen.main.bounds.width, UIScreen.main.bounds.height)) .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
.tabViewStyle(PageTabViewStyle())
}
}
}