首页 > 解决方案 > SwiftUI TabView on WatchOS breaks when a ScrollView is nested inside. SwiftUI bug or coding error?

问题描述

So I've noticed that TabView loses horizontal swiping between tabs when any type of ScrollView is nested inside. This includes ScrollView and List. Wondering if this is a bug I can just wait for a fix or if I'm making a mistake in my code. Any insight is appreciated.

This code works as expected:

TabView {
  Text("Tab 1")
  Text("Tab 2")
}

This code will freeze on "Tab 1" and horizontal swiping between tabs doesn't work:

TabView {
  ScrollView {
    Text("Tab 1")
  }
  Text("Tab 2")
}

标签: watchosswiftui

解决方案


推荐阅读