I am having some issues when rotating a paging TabView. I have the following code:
struct ContentView: View {
var body: some View {
ZStack {
Color(.systemGroupedBackground)
.edgesIgnoringSafeArea(.all)
TabView {
ForEach(users, id: \.self) { user in
CardView(user: user)
}
}
.tabViewStyle(PageTabViewStyle())
.background(Color(.systemGroupedBackground))
}
}
}
struct CardView: View {
var body: some View {
ZStack {
Color.white
Image("someImage")
.resizable()
.aspectRatio(contentMode: .fill)
}
.cornerRadius(16)
.padding([.top, .horizontal], 30)
.padding([.bottom], 50)
}
}
When I rotate to landscape and then start to page through the cards I notice some of the cards are still in Portrait with the content clipped despite the fact that the device is in landscape. It seems to happen randomly and only effect a few cards. I tried to listen for rotation and then toggle a state var to see if the view would redraw correctly after rotation but it makes no difference whatsoever. Not sure if this is a bug or how to rectify.