在SwiftUI中只是一个简单的选项卡式应用xcodeproj。
添加一个类似aaand的选择器:切换到第二个标签时在运行时崩溃。
import SwiftUI
struct ContentView : View {
@State private var selection = 0
@State private var pickerselection = 3
let numbers = ["1", "2", "3", "4", "5"]
var aTitle: String = "Title"
var body: some View {
TabbedView(selection: $selection) {
// ADD ONLY THIS PART TO A NEW TABBED APP SWIFTUI PROJECT //// BEGIN /////
VStack{
Text("First View")
.font(.title)
Picker(selection: $pickerselection, label:
Text(aTitle)) {
ForEach(0 ..< numbers.count) { index in
Text(self.numbers[index]).tag(index)
}
}
}
////// XCODE 11.0 BETA 2 ONLY//////// END ////////////
.tabItemLabel(Image("first"))
.tag(0)
Text("Second View")
.font(.title)
.tabItemLabel(Image("second"))
.tag(1)
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
编译,但是在切换选项卡时运行时崩溃:
线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x8)
答案 0 :(得分:0)
问题似乎在XCode 11 beta 5中得到了解决。