I have this struct in my code:
struct TabsController: View {
@State var selectedView = 1
init(_ selectedView: Int) {
self.selectedView = selectedView
}
var body: some View {
TabView(selection: $selectedView){
}
}
}
And this one in another view:
self.viewControllerHolder?.present(style: .fullScreen) {
TabsController(3)
}
What i'm trying to do is to present the tabView with the third item selected. However, it doesn't work. I tried the following:
init(_ selectedView: Int) {
self.selectedView = selectedView
print("\(self.selectedView)")
print("\(selectedView)")
}
And it showed 1 and 3, respectively, but the value still didn't change.