Post

Replies

Boosts

Views

Activity

Mac Catalyst 18 TabView selection binding broken
I think I've found a bug with SwiftUI TabView selection binding on Mac Catalyst 18. This code prints to the console when the SceneStorage variable for the TabView selection changes. If you run the code below on iOS and change the tab, the selection prints to the console indicating the SceneStorage variable has changed. If you run the code below on Mac Catalyst 18 in Sequoia and change the tab, the selection does not print to the console indicating the SceneStorage variable has not changed. Looking for input please before I turn this over to Apple code-level support. // // ContentView.swift // tabview-catalyst-issue // import SwiftUI import os.log enum TabDisplay: String, CaseIterable, Identifiable { case list case grid var id: String { self.rawValue } } struct ContentView: View { @SceneStorage("selectedTabView") var selectedTabView = TabDisplay.list var body: some View { VStack { TabView(selection: $selectedTabView) { Text("LIST") .tabItem { Image(systemName: "list.bullet") Text("List") } .tag(TabDisplay.list) Text("GRID") .tabItem { Image(systemName: "rectangle.split.3x3") Text("Grid") } .tag(TabDisplay.grid) } } .padding() .onChange(of: self.selectedTabView, perform: { value in // Added to show that the TabView binding doesn't work in Mac Catalyst 18 print(value) }) } } #Preview { ContentView() }
5
0
321
Oct ’24
How to fix the Core Data / SwiftUI 2.0 template in Xcode 12
In Xcode 12, does the CoreData / SwiftUI 2.0 template give you an app that only displays a white screen? Well... In ContentView, replace the body with this... var body: some View { NavigationView { List { ForEach(items) { item in Text("Item at \(item.timestamp!, formatter: itemFormatter)") } .onDelete(perform: deleteItems) } .toolbar { ToolbarItem(placement: .navigationBarLeading) { #if os(iOS) EditButton() #endif } ToolbarItem(placement: .navigationBarTrailing) { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } } }
4
0
1.9k
Sep ’20