Post

Replies

Boosts

Views

Activity

SwiftData and CloudKit Issues
Hi, I'm using SwiftData in my app, and I want to sent data to iCloud with CloudKit, but I found that If the user turns off my App iCloud sync function in the settings App, the local data will also be deleted. A better way is maintaining the local data, just don't connect to iCloud.How should I do that? I need guidance!!! I'm just getting started with CloudKit And I would be appreciated!
1
0
329
Nov ’25
In navigationLink closure, FocusState doesn't work in sheet
Hello, I have a question about FocusState, navigationLink and sheet, the code which in navigationLink closure doesn’t work, but work without navigationLink, just like the following code struct ContentView: View { var body: some View { NavigationStack { // this work interView() // this doesn't work NavigationLink { interView() } label: { Text("into interView") } } } } struct interView: View { @FocusState var focusStateA : Int? @State var show : Bool = false @State var text: String = "" var body: some View { ScrollView { VStack { coreView Button("Detail") { show.toggle() } } .sheet(isPresented: $show, content: { coreView }) } } } extension interView { var coreView : some View { VStack { VStack { putdown TextField("hi", text: $text) .focused($focusStateA , equals: 1) } } } var putdown : some View { Button(action: { if focusStateA != nil { focusStateA = nil print("OK") } else { print("It's nil") } }, label: { Text("Put down the keyboard") }) } } and there are some strange phenomena, I must put all view into a scrollview, otherwise, it even doesn’t work without navigationLink This problem has existed in IOS 18, and now in IOS26 still doesn’t be settled, is it a problem or some character?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
64
Jun ’25
SwiftUI TabView(.sidebarAdaptable) does not reliably animate content resize when switching between sidebar and top tab bar on iPad
Hi everyone, I’m building an iPad app in SwiftUI using the adaptive tab navigation pattern: Tab(value: .overview) { OverviewView() } label: { Label("Overview", systemImage: "archivebox") } Tab(value: .gallery) { GalleryView() } label: { Label("Gallery", systemImage: "shippingbox") } Tab(value: .canvas) { CanvasView() } label: { Label("Canvas", systemImage: "rectangle") } Tab(value: .record) { recordView } label: { Label("Record", systemImage: "plus") } } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($tabCustomization) The issue is that when the adaptive tab bar switches between the sidebar placement and the top bar placement on iPad, the content area resize animation is unreliable. The system navigation chrome changes correctly, but some tab contents jump directly to their final width instead of smoothly animating with the sidebar/top bar transition. Interestingly, one of my record views appears to animate consistently, so it seems the system transition itself is possible, but some view hierarchy or navigation structure may be preventing the animation in other tabs. Each major tab currently owns its own NavigationStack. For example, OverviewView, GalleryView, and CanvasView each have a NavigationStack as their root view. The Record tab conditionally shows different recording views, and one of those views also contains its own NavigationStack. I have already tried several approaches, but none solved the issue reliably: Observing @Environment(.tabBarPlacement) and adding .animation(..., value:) Reporting tabBarPlacement upward using a PreferenceKey and wrapping the update in withAnimation Wrapping tab contents in GeometryReader or other outer layout containers Temporarily removing .tabViewCustomization($tabCustomization) and .customizationID(...) Reducing the implementation to the simplest documented TabView(selection:) + Tab(...) + .tabViewStyle(.sidebarAdaptable) structure Some of these attempts actually made the animation behavior worse, so I reverted them. My questions are: 1.Is the content area expected to animate automatically when TabView(.sidebarAdaptable) changes between sidebar and top bar placement on iPad? 2.Is it recommended for each tab to own its own NavigationStack in this setup? 3.Could tabViewCustomization(:) or customizationID(:) affect the sidebar/top bar transition animation? 4.Is there an official SwiftUI pattern for preserving the system animation transaction during this adaptive tab bar placement change? 5.If this is expected behavior or a current limitation, what structure would Apple recommend for this kind of iPad navigation? Thanks in advance!
Topic: UI Frameworks SubTopic: SwiftUI
0
0
59
2d
SwiftData and CloudKit Issues
Hi, I'm using SwiftData in my app, and I want to sent data to iCloud with CloudKit, but I found that If the user turns off my App iCloud sync function in the settings App, the local data will also be deleted. A better way is maintaining the local data, just don't connect to iCloud.How should I do that? I need guidance!!! I'm just getting started with CloudKit And I would be appreciated!
Replies
1
Boosts
0
Views
329
Activity
Nov ’25
In navigationLink closure, FocusState doesn't work in sheet
Hello, I have a question about FocusState, navigationLink and sheet, the code which in navigationLink closure doesn’t work, but work without navigationLink, just like the following code struct ContentView: View { var body: some View { NavigationStack { // this work interView() // this doesn't work NavigationLink { interView() } label: { Text("into interView") } } } } struct interView: View { @FocusState var focusStateA : Int? @State var show : Bool = false @State var text: String = "" var body: some View { ScrollView { VStack { coreView Button("Detail") { show.toggle() } } .sheet(isPresented: $show, content: { coreView }) } } } extension interView { var coreView : some View { VStack { VStack { putdown TextField("hi", text: $text) .focused($focusStateA , equals: 1) } } } var putdown : some View { Button(action: { if focusStateA != nil { focusStateA = nil print("OK") } else { print("It's nil") } }, label: { Text("Put down the keyboard") }) } } and there are some strange phenomena, I must put all view into a scrollview, otherwise, it even doesn’t work without navigationLink This problem has existed in IOS 18, and now in IOS26 still doesn’t be settled, is it a problem or some character?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
64
Activity
Jun ’25
SwiftUI TabView(.sidebarAdaptable) does not reliably animate content resize when switching between sidebar and top tab bar on iPad
Hi everyone, I’m building an iPad app in SwiftUI using the adaptive tab navigation pattern: Tab(value: .overview) { OverviewView() } label: { Label("Overview", systemImage: "archivebox") } Tab(value: .gallery) { GalleryView() } label: { Label("Gallery", systemImage: "shippingbox") } Tab(value: .canvas) { CanvasView() } label: { Label("Canvas", systemImage: "rectangle") } Tab(value: .record) { recordView } label: { Label("Record", systemImage: "plus") } } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($tabCustomization) The issue is that when the adaptive tab bar switches between the sidebar placement and the top bar placement on iPad, the content area resize animation is unreliable. The system navigation chrome changes correctly, but some tab contents jump directly to their final width instead of smoothly animating with the sidebar/top bar transition. Interestingly, one of my record views appears to animate consistently, so it seems the system transition itself is possible, but some view hierarchy or navigation structure may be preventing the animation in other tabs. Each major tab currently owns its own NavigationStack. For example, OverviewView, GalleryView, and CanvasView each have a NavigationStack as their root view. The Record tab conditionally shows different recording views, and one of those views also contains its own NavigationStack. I have already tried several approaches, but none solved the issue reliably: Observing @Environment(.tabBarPlacement) and adding .animation(..., value:) Reporting tabBarPlacement upward using a PreferenceKey and wrapping the update in withAnimation Wrapping tab contents in GeometryReader or other outer layout containers Temporarily removing .tabViewCustomization($tabCustomization) and .customizationID(...) Reducing the implementation to the simplest documented TabView(selection:) + Tab(...) + .tabViewStyle(.sidebarAdaptable) structure Some of these attempts actually made the animation behavior worse, so I reverted them. My questions are: 1.Is the content area expected to animate automatically when TabView(.sidebarAdaptable) changes between sidebar and top bar placement on iPad? 2.Is it recommended for each tab to own its own NavigationStack in this setup? 3.Could tabViewCustomization(:) or customizationID(:) affect the sidebar/top bar transition animation? 4.Is there an official SwiftUI pattern for preserving the system animation transaction during this adaptive tab bar placement change? 5.If this is expected behavior or a current limitation, what structure would Apple recommend for this kind of iPad navigation? Thanks in advance!
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
59
Activity
2d