Search results for

“swiftui”

17,491 results found

Post

Replies

Boosts

Views

Activity

Reply to Issue keeping scroll position in SwiftUI
Hey there! Still don't get any answer about this topic so I take the advantage of the WWDC to reopen it. I really would like to ensure I have not missed something. I did the full implementation using UIKit UICollectionView using performBatchUpdates to deal with my double sided pagination. But I still have some crashes issues or even strange animation when scrolling up to load above pages. So here are my 2 questions Is there a way to accomplish natively and properly a double-sided pagination in UIKit? Is this possible in SwiftUI? I'm attending WWDC this year so I would be happy to discuss irl about that topic. Best
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
Reply to SwiftUI Liquid Glass Menu briefly turns black after dismissing before returning to transparent glass
I’m seeing what looks like the same issue in my app as well. In my case, I have a top control pill that uses Liquid Glass, and inside that pill there are two SwiftUI Menu buttons. The issue happens with both menu buttons: one uses the line.3.horizontal.decrease symbol and the other uses the number symbol. The glass pill normally renders correctly, but after opening and dismissing one of the menus, the control briefly appears as a solid/dark pill before returning to the expected transparent Liquid Glass appearance. Here is the relevant structure from my code: private var displayOptionsPill: some View { HStack(spacing: 0) { filterMenuButtonInPill displayModeMenuButtonInPill } .padding(.horizontal, 6) .frame(height: 44) .glassEffect(.regular.interactive(), in: Capsule()) } private var filterMenuButtonInPill: some View { Menu { filterMenuContent } label: { Image(systemName: line.3.horizontal.decrease) .font(.title2) .fontWeight(.medium) .foregroundStyle(.primary) .frame(width: 38, height: 32) .contentSha
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
Reply to Can APNs wake a sleeping Mac for a third-party app?
After trying every option I can find, I don't believe notifications can wake a sleeping Mac and allow my third-party app to process data, but I really want to be wrong. Can anyone confirm whether or not this is possible? I'll cover a few details below but the short summary is that, no, I don't think this will really work, at least not in a way that's reliably tied to the notification itself. Getting into some specifics, let me start with some background context: Wake for Network Access This particular setting actually controls a ethernet hardware level feature called Wake-on-LAN (WoL). How this actually works is that the ethernet controller itself passively monitors the bus watching for a very particular packet (the magic packet), waking the machine up if it ever receives it. The critical point to that is that this ISN'T a generic wake me up for any traffic mechanism. It has very specific contents (notably, the device MAC address) and generally only originates from with the local network, not from a remote ho
Jun ’26
Reply to iOS 26: Enabling "Reduce Transparency" causes a persistent white bar where the tab bar was hidden, blocking user interaction
@DTS Engineer Sure! Please try this code with the Settings → Accessibility → Display & Text Size → Reduce Transparency option enabled. Feedback ID: FB22913365 import SwiftUI struct ContentView: View { @State var tab = 0 var body: some View { TabView(selection: $tab) { TabContentView() .tabItem { Label(One, image: ) } .tag(0) TabContentView() .tabItem { Label(Two, image: ) } .tag(1) } } } struct TabContentView: View { @State var path = [Int]() var body: some View { NavigationStack(path: $path) { NavigationStackFirstView(onNext: { path.append(0) }) .navigationDestination(for: Int.self) { destination in Group { switch destination { case 0: NavigationStackSecondView() default: EmptyView() } } .toolbar(.hidden, for: .tabBar) } } .navigationViewStyle(StackNavigationViewStyle()) } } struct NavigationStackFirstView: View { let onNext: () -> Void var body: some View { VStack { Text(View with tabbar) .font(.system(size: 24)) .padding() Button(Go to view without tabbar) { onNext() } } .frame(maxWidth: .i
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
Reality View Preserves Camera Transform when toggling Virtual & Spatial Tracking modes
When switching from RealityView’s .spatialTracking camera mode to .virtual camera mode, the camera’s orientation relative to the scene is preserved permanently with no way to reset to default World-Up orientation. Since .spatialTracking’s camera mode will always have a non-default orientation, switching to .virtual camera mode ensures that the cameras’s ‘UP’ direction will never match the device display’s ‘UP’ direction as is default. This is especially noticeable when using .orbit camera controls, as the orbit’s UP direction matches the scene, not camera, and all rotation directions give unexpected results. Expected: When setting virtual camera mode after using spatialTracking camera mode, either 1. The Virtual Camera orientation returns to default (world up). Or 2. A 'content.camera.resetOrientation()' call is made available which resets the RealityView camera to default orientation. Reality: Switching from .spatialTracking -> .virtual camera mode permanently locks the .virtual camera’s orientation the f
1
0
559
Jun ’26
Reply to SecureField dots invisible in dark mode when iOS suggests and fills a strong password
@SergioDCQ Thanks for the interesting observation. I didn't copy your code but looking at the dark setting I got the idea of what is happening, I think. When iOS suggests and fills a strong password, it forces the underlying TextField's background to yellow and its text color to black (to ensure the text is readable against the yellow highlight). When the yellow highlight fades out, the system is supposed to restore the original text color. However, because you are using a hardcoded color (colorScheme == .dark ? .white : .black) Since SwiftUI's state hasn't changed, it never re-applies the .white color, leaving you with invisible black dots on a black background. Instead of manually switching between .white and .black, use SwiftUI's semantic .primary color (or Color(uiColor: .label)). Replace your .foregroundColor modifiers on the TextFields with .foregroundStyle(.primary) you can force SwiftUI to re-apply the text color by slightly changing the color value when the password is auto
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
Reply to SecureField dots invisible in dark mode when iOS suggests and fills a strong password
@SergioDCQ Thanks for the interesting observation. I didn't copy your code but looking at the dark setting I got the idea of what is happening, I think. When iOS suggests and fills a strong password, it forces the underlying TextField's background to yellow and its text color to black (to ensure the text is readable against the yellow highlight). When the yellow highlight fades out, the system is supposed to restore the original text color. However, because you are using a hardcoded color (colorScheme == .dark ? .white : .black) Since SwiftUI's state hasn't changed, it never re-applies the .white color, leaving you with invisible black dots on a black background. Instead of manually switching between .white and .black, use SwiftUI's semantic .primary color (or Color(uiColor: .label)). Replace your .foregroundColor modifiers on the TextFields with .foregroundStyle(.primary) you can force SwiftUI to re-apply the text color by slightly changing the color value when the password is auto
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
Reply to How to set the Locale.current to be same as the Environment locale?
Hi, Sorry to hear you are having trouble viewing different locales while using previews. Unfortunately you have here found a situation where overriding the locale in the environment doesn't work for APIs that don't interact or read from the SwiftUI environment (Formatters is another common one folks are impacted by). The only suggestion I have for now is to use the scheme picker's UI affordance to manually switch between locales/languages as opposed to just overriding the SwiftUI environment's Locale.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’26
Reply to NSFileSandboxingRequestRelatedItemExtension: Failed to issue extension
I explicitly choose SwiftUI... so I will have to wait for the feature to appear again... I will not go back - especially since the apps I am currently developing shall work on Mac/iOS and SwiftUI makes that rather easy while building native apps ;) Fair enough. The one thing I'll add here is that, particularly in terms of new development, I'd suggest trying to design your product in ways that intentionally avoid relying on related item support. While this should work, by definition, you're getting access to a file the user didn't explicitly give you access to, which means it's also an area with significant security implications and higher risk of failure. __ Kevin Elliott DTS Engineer, CoreOS/Hardware
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’26
SecureField dots invisible in dark mode when iOS suggests and fills a strong password
I am using SwiftUI's native SecureField. When a user types their password manually, the dots render correctly in both light and dark mode. However, when iOS suggests and autofills a strong generated password, the dots become invisible in dark mode. Switching to light mode shows that they are there. Is there a supported way to force SecureField to re-render its secure entry dots correctly after iOS fills in a strong generated password in dark mode? import SwiftUI let warmMustard = Color(red: 0.780, green: 0.659, blue: 0.290) let lightText = Color(red: 0.973, green: 0.961, blue: 0.933) let darkText = Color(red: 0.118, green: 0.118, blue: 0.118) struct SecureFieldTestView: View { @Environment(.colorScheme) var colorScheme @State private var username = @State private var password = @State private var confirmPassword = var body: some View { ZStack { Color(colorScheme == .dark ? UIColor.black : UIColor.white) .ignoresSafeArea() VStack(spacing: 20) { Text(Dark mode dot reproduction) .foregroundC
2
0
388
Jun ’26
889 CoreData errors in a SwiftData app of less than 30 lines
I have created a SwiftData iOS app from Paul Hudson's Hacking With Swift series in order to troubleshoot some SwiftData issues I am having in a separate app. I have raised > FB22925785 I have gone back to basics to try and problem solve so I have used the first part of an app of Paul's from [https://www.hackingwithswift.com/quick-start/swiftdata/defining-a-data-model-with-swiftdata] The App is very simple and only contains the following import SwiftData import SwiftUI @main struct iTour_from_scratchApp: App { var body: some Scene { WindowGroup { ContentView() .modelContainer(for: Destination.self) } } } The data is import SwiftData @Model class Destination { var name: String var details: String var date: Date var priority: Int init(name: String, details: String, date: Date, priority: Int) { self.name = name self.details = details self.date = date self.priority = priority } } The view is import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: globe) .imag
1
0
627
Jun ’26
manageSubscriptionsSheet resulting in "No connection"
I have an iOS app (SwiftUI) that includes recurring subscriptions. To allow users to manage their subscriptions I have implemented manageSubscriptionsSheet according to apple documentation. When I published the app last year for iOS17 and iOS18 this was working well. Now I have gotten a user report that this features yields No connection error instead of the abonnements on iOS26. I have tested on my iPad running iOS 26 as well as on the simulator with iOS 26 and 18. In all cases I get the error. I can press Retry in the dialog and am prompted for AppStore credentials After entering them, again the same error. I can not find a single hint on why and how to fix it. Best wishes, Volker
3
0
353
Jun ’26
AttributedString Localization does not seem to work
I have this code struct TestAppleSuggestion: View { @Environment(.locale) var locale: Locale var body: some View { VStack { VStack { Text(locale: (locale.identifier)) Text(AttributedString(localized: LocalizedStringResource( welcome, locale: locale ))) Text(AttributedString(localized: welcome, locale: locale )) } } } } #Preview { TestAppleSuggestion().environment(.locale, Locale(identifier: fr-CA)) } Heres What I see in SwiftUi Previews The Localization is working for the LocalizedStringResource but not to the AttributedString. Why?
3
0
395
Jun ’26
Reply to Issue keeping scroll position in SwiftUI
Hey there! Still don't get any answer about this topic so I take the advantage of the WWDC to reopen it. I really would like to ensure I have not missed something. I did the full implementation using UIKit UICollectionView using performBatchUpdates to deal with my double sided pagination. But I still have some crashes issues or even strange animation when scrolling up to load above pages. So here are my 2 questions Is there a way to accomplish natively and properly a double-sided pagination in UIKit? Is this possible in SwiftUI? I'm attending WWDC this year so I would be happy to discuss irl about that topic. Best
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reply to SwiftUI Liquid Glass Menu briefly turns black after dismissing before returning to transparent glass
I’m seeing what looks like the same issue in my app as well. In my case, I have a top control pill that uses Liquid Glass, and inside that pill there are two SwiftUI Menu buttons. The issue happens with both menu buttons: one uses the line.3.horizontal.decrease symbol and the other uses the number symbol. The glass pill normally renders correctly, but after opening and dismissing one of the menus, the control briefly appears as a solid/dark pill before returning to the expected transparent Liquid Glass appearance. Here is the relevant structure from my code: private var displayOptionsPill: some View { HStack(spacing: 0) { filterMenuButtonInPill displayModeMenuButtonInPill } .padding(.horizontal, 6) .frame(height: 44) .glassEffect(.regular.interactive(), in: Capsule()) } private var filterMenuButtonInPill: some View { Menu { filterMenuContent } label: { Image(systemName: line.3.horizontal.decrease) .font(.title2) .fontWeight(.medium) .foregroundStyle(.primary) .frame(width: 38, height: 32) .contentSha
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reply to Can APNs wake a sleeping Mac for a third-party app?
After trying every option I can find, I don't believe notifications can wake a sleeping Mac and allow my third-party app to process data, but I really want to be wrong. Can anyone confirm whether or not this is possible? I'll cover a few details below but the short summary is that, no, I don't think this will really work, at least not in a way that's reliably tied to the notification itself. Getting into some specifics, let me start with some background context: Wake for Network Access This particular setting actually controls a ethernet hardware level feature called Wake-on-LAN (WoL). How this actually works is that the ethernet controller itself passively monitors the bus watching for a very particular packet (the magic packet), waking the machine up if it ever receives it. The critical point to that is that this ISN'T a generic wake me up for any traffic mechanism. It has very specific contents (notably, the device MAC address) and generally only originates from with the local network, not from a remote ho
Replies
Boosts
Views
Activity
Jun ’26
Reply to iOS 26: Enabling "Reduce Transparency" causes a persistent white bar where the tab bar was hidden, blocking user interaction
@DTS Engineer Sure! Please try this code with the Settings → Accessibility → Display & Text Size → Reduce Transparency option enabled. Feedback ID: FB22913365 import SwiftUI struct ContentView: View { @State var tab = 0 var body: some View { TabView(selection: $tab) { TabContentView() .tabItem { Label(One, image: ) } .tag(0) TabContentView() .tabItem { Label(Two, image: ) } .tag(1) } } } struct TabContentView: View { @State var path = [Int]() var body: some View { NavigationStack(path: $path) { NavigationStackFirstView(onNext: { path.append(0) }) .navigationDestination(for: Int.self) { destination in Group { switch destination { case 0: NavigationStackSecondView() default: EmptyView() } } .toolbar(.hidden, for: .tabBar) } } .navigationViewStyle(StackNavigationViewStyle()) } } struct NavigationStackFirstView: View { let onNext: () -> Void var body: some View { VStack { Text(View with tabbar) .font(.system(size: 24)) .padding() Button(Go to view without tabbar) { onNext() } } .frame(maxWidth: .i
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reality View Preserves Camera Transform when toggling Virtual & Spatial Tracking modes
When switching from RealityView’s .spatialTracking camera mode to .virtual camera mode, the camera’s orientation relative to the scene is preserved permanently with no way to reset to default World-Up orientation. Since .spatialTracking’s camera mode will always have a non-default orientation, switching to .virtual camera mode ensures that the cameras’s ‘UP’ direction will never match the device display’s ‘UP’ direction as is default. This is especially noticeable when using .orbit camera controls, as the orbit’s UP direction matches the scene, not camera, and all rotation directions give unexpected results. Expected: When setting virtual camera mode after using spatialTracking camera mode, either 1. The Virtual Camera orientation returns to default (world up). Or 2. A 'content.camera.resetOrientation()' call is made available which resets the RealityView camera to default orientation. Reality: Switching from .spatialTracking -> .virtual camera mode permanently locks the .virtual camera’s orientation the f
Replies
1
Boosts
0
Views
559
Activity
Jun ’26
Reply to SecureField dots invisible in dark mode when iOS suggests and fills a strong password
@SergioDCQ Thanks for the interesting observation. I didn't copy your code but looking at the dark setting I got the idea of what is happening, I think. When iOS suggests and fills a strong password, it forces the underlying TextField's background to yellow and its text color to black (to ensure the text is readable against the yellow highlight). When the yellow highlight fades out, the system is supposed to restore the original text color. However, because you are using a hardcoded color (colorScheme == .dark ? .white : .black) Since SwiftUI's state hasn't changed, it never re-applies the .white color, leaving you with invisible black dots on a black background. Instead of manually switching between .white and .black, use SwiftUI's semantic .primary color (or Color(uiColor: .label)). Replace your .foregroundColor modifiers on the TextFields with .foregroundStyle(.primary) you can force SwiftUI to re-apply the text color by slightly changing the color value when the password is auto
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reply to SecureField dots invisible in dark mode when iOS suggests and fills a strong password
@SergioDCQ Thanks for the interesting observation. I didn't copy your code but looking at the dark setting I got the idea of what is happening, I think. When iOS suggests and fills a strong password, it forces the underlying TextField's background to yellow and its text color to black (to ensure the text is readable against the yellow highlight). When the yellow highlight fades out, the system is supposed to restore the original text color. However, because you are using a hardcoded color (colorScheme == .dark ? .white : .black) Since SwiftUI's state hasn't changed, it never re-applies the .white color, leaving you with invisible black dots on a black background. Instead of manually switching between .white and .black, use SwiftUI's semantic .primary color (or Color(uiColor: .label)). Replace your .foregroundColor modifiers on the TextFields with .foregroundStyle(.primary) you can force SwiftUI to re-apply the text color by slightly changing the color value when the password is auto
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reply to How to set the Locale.current to be same as the Environment locale?
Hi, Sorry to hear you are having trouble viewing different locales while using previews. Unfortunately you have here found a situation where overriding the locale in the environment doesn't work for APIs that don't interact or read from the SwiftUI environment (Formatters is another common one folks are impacted by). The only suggestion I have for now is to use the scheme picker's UI affordance to manually switch between locales/languages as opposed to just overriding the SwiftUI environment's Locale.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
Reply to NSFileSandboxingRequestRelatedItemExtension: Failed to issue extension
I explicitly choose SwiftUI... so I will have to wait for the feature to appear again... I will not go back - especially since the apps I am currently developing shall work on Mac/iOS and SwiftUI makes that rather easy while building native apps ;) Fair enough. The one thing I'll add here is that, particularly in terms of new development, I'd suggest trying to design your product in ways that intentionally avoid relying on related item support. While this should work, by definition, you're getting access to a file the user didn't explicitly give you access to, which means it's also an area with significant security implications and higher risk of failure. __ Kevin Elliott DTS Engineer, CoreOS/Hardware
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’26
SecureField dots invisible in dark mode when iOS suggests and fills a strong password
I am using SwiftUI's native SecureField. When a user types their password manually, the dots render correctly in both light and dark mode. However, when iOS suggests and autofills a strong generated password, the dots become invisible in dark mode. Switching to light mode shows that they are there. Is there a supported way to force SecureField to re-render its secure entry dots correctly after iOS fills in a strong generated password in dark mode? import SwiftUI let warmMustard = Color(red: 0.780, green: 0.659, blue: 0.290) let lightText = Color(red: 0.973, green: 0.961, blue: 0.933) let darkText = Color(red: 0.118, green: 0.118, blue: 0.118) struct SecureFieldTestView: View { @Environment(.colorScheme) var colorScheme @State private var username = @State private var password = @State private var confirmPassword = var body: some View { ZStack { Color(colorScheme == .dark ? UIColor.black : UIColor.white) .ignoresSafeArea() VStack(spacing: 20) { Text(Dark mode dot reproduction) .foregroundC
Replies
2
Boosts
0
Views
388
Activity
Jun ’26
889 CoreData errors in a SwiftData app of less than 30 lines
I have created a SwiftData iOS app from Paul Hudson's Hacking With Swift series in order to troubleshoot some SwiftData issues I am having in a separate app. I have raised > FB22925785 I have gone back to basics to try and problem solve so I have used the first part of an app of Paul's from [https://www.hackingwithswift.com/quick-start/swiftdata/defining-a-data-model-with-swiftdata] The App is very simple and only contains the following import SwiftData import SwiftUI @main struct iTour_from_scratchApp: App { var body: some Scene { WindowGroup { ContentView() .modelContainer(for: Destination.self) } } } The data is import SwiftData @Model class Destination { var name: String var details: String var date: Date var priority: Int init(name: String, details: String, date: Date, priority: Int) { self.name = name self.details = details self.date = date self.priority = priority } } The view is import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: globe) .imag
Replies
1
Boosts
0
Views
627
Activity
Jun ’26
Reply to AttributedString Localization does not seem to work
is there a secure way for me to send the project to you? or maybe you can share your project? I observed the issue in SwiftUi Previews.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’26
manageSubscriptionsSheet resulting in "No connection"
I have an iOS app (SwiftUI) that includes recurring subscriptions. To allow users to manage their subscriptions I have implemented manageSubscriptionsSheet according to apple documentation. When I published the app last year for iOS17 and iOS18 this was working well. Now I have gotten a user report that this features yields No connection error instead of the abonnements on iOS26. I have tested on my iPad running iOS 26 as well as on the simulator with iOS 26 and 18. In all cases I get the error. I can press Retry in the dialog and am prompted for AppStore credentials After entering them, again the same error. I can not find a single hint on why and how to fix it. Best wishes, Volker
Replies
3
Boosts
0
Views
353
Activity
Jun ’26
Reply to NSFileSandboxingRequestRelatedItemExtension: Failed to issue extension
Thanks Kevin! I explicitly choose SwiftUI... so I will have to wait for the feature to appear again... I will not go back - especially since the apps I am currently developing shall work on Mac/iOS and SwiftUI makes that rather easy while building native apps ;) Best wishes, Volker
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’26
AttributedString Localization does not seem to work
I have this code struct TestAppleSuggestion: View { @Environment(.locale) var locale: Locale var body: some View { VStack { VStack { Text(locale: (locale.identifier)) Text(AttributedString(localized: LocalizedStringResource( welcome, locale: locale ))) Text(AttributedString(localized: welcome, locale: locale )) } } } } #Preview { TestAppleSuggestion().environment(.locale, Locale(identifier: fr-CA)) } Heres What I see in SwiftUi Previews The Localization is working for the LocalizedStringResource but not to the AttributedString. Why?
Replies
3
Boosts
0
Views
395
Activity
Jun ’26