Search results for

swiftui

16,623 results found

Post

Replies

Boosts

Views

Activity

Reply to List jumps back to the top
Thanks @Claude31, I have found stuff like that, yeah. For the section in my list that can be expanded and contracted, ScrollViewReader and .scrollTo work to keep you in the right place, so thanks for the hint. This is the code for the List, if it helps: ScrollViewReader { proxy in List { // Standard items ForEach(modelData.filteredItems.filter { !$0.archived }) { item in ItemRow(item) } // Archived items if(modelData.filteredItems.filter { $0.archived }.count > 0) { ListSectionHeader_Archived() .id(ListSectionHeader_Archived) .onTapGesture { modelData.archivedItemsExpanded.toggle() DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { proxy.scrollTo(ListSectionHeader_Archived) } } if(modelData.archivedItemsExpanded) { ForEach(modelData.filteredItems.filter { $0.archived }) { item in ItemRow(item) } } } } // List .id(UUID()) } I still can't figure out a way to stop the list from jumping back to the top when the device's Dark Mode setting changes. Why does SwiftUI think the data is different?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to Scrolling UICollectionView inside a container view scrolls navigation controller title
Hey, what is the best way to do something similar in the SwiftUI world? I'm trying to stop the title being affected by scrolling a list with a static header. In this example scrolling the list pulls the title down over Heading, which remains static. Ideally the title wouldn't be affected. Many thanks in advance extension String: Identifiable { public var id: Int { hashValue } } struct ContentView: View { static let items = [a, b, c] var body: some View { NavigationStack { VStack { Text(Heading) List(ContentView.items) { item in Text(item) } .listStyle(.plain) .navigationTitle(Title) } .padding() } } } #Preview { ContentView() }
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’25
Reply to List jumps back to the top
If that may help, I found this, but did not test, using ScrollViewReader, but you've probably found as well: Get the scroll position: https://stackoverflow.com/questions/62588015/get-the-current-scroll-position-of-a-swiftui-scrollview Set the scroll position (in .onAppear ?): https://www.hackingwithswift.com/quick-start/swiftui/how-to-scroll-to-a-specific-row-in-a-list Or would it be enough to set the selection when it exists ? https://stackoverflow.com/questions/74365665/force-deselection-of-row-in-swiftui-list-view/74368833#74368833
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to System Data Occupying Half of My Storage
If you develop software in SwiftUI, you should know better. Every time you initiate an Xcode project, a new folder with a ton of data is created inside the DerivedData folder. If you duplicate an existing Xcode project, a duplicate after the Xcode project name will be created in the DrivedData folder. I occasionally go to the DerivedData folder and delete the folders that I no longer keep track of although my Mac mini gives me 512 GB of space.
Oct ’25
How to prevent VoiceOver from reading text INSIDE an image?
In the example below, VoiceOver (in both iOS 18 and 26) reads the text contained within the image after the .accessibilityLabel, introduced by a “beep.” VoiceOver: Purple rounded square with the word 'Foo' in white letters. Image [beep] foo. I’d like it to only read the accessibility label. As a developer focused on accessibility, I make sure every image already has an appropriate label, so having iOS read the image text is redundant. Sample Code import SwiftUI struct ContentView: View { var body: some View { Image(TextInImage) .resizable() .scaledToFit() .frame(width: 64, height: 64) .accessibilityLabel(Purple rounded square with the word 'Foo' in white letters.) } } Sample Image Drop this image in to Assets.xcassets and confirm it's named TextInImage.
4
0
222
Oct ’25
Prevent default file selector in a SwiftUI DocumentGroup app and show a custom welcome window on launch
I’m building a macOS document based app using SwiftUI’s DocumentGroup API. By default, when a document based app launches, macOS automatically shows a file open panel or creates a new untitled document window. However, I want to suppress this default behavior and instead show a custom welcome window when the app starts — something similar to how Xcode or Final Cut Pro shows a “Welcome” or “Start Project” screen first. So basically, when the user opens the app normally, it should not open the document selector or create a document automatically. Instead, it should show my custom SwiftUI or AppKit window. Here is my Code :- //MyApp.swift import SwiftUI import AppKit @main struct PhiaApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate var body: some Scene { DocumentGroup(newDocument: MyDocumentModel()) { file in EditorView(document: file.document, filePath: file.fileURL) } Settings { EmptyView() } } } Current I have this code setup for my MainApp.swift, where I a
2
0
206
Oct ’25
Reply to XCode26 doesnt compile PhotosUI properly
I’m not sure what’s going on here, but it seems to be something specific to your project. Here’s what I did: Using Xcode 26.0.1 on macOS 15.7.1, I created a new test project from the iOS > App template, choosing SwiftUI for the UI. I modified the top of ContentView.swift to look like this: import SwiftUI import PhotosUI let something = PHPickerViewControllerDelegate.self I build the app for the simulator and the device. Both worked fine. My recommendation is that you repeat these steps. If those work for you, that’ll confirm that this issue is tied to your project rather than something environmental. I’ll also give you know good and known bad cases to compare. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Oct ’25
SwiftUI preview failed, help!!!!!
When I update the macOS from 15.5 to 15.6, Preview error. 1、I try remove simulator cache, sdk 2、remove Xcode build cache 3、reinstall Xcode 4、try with this method https://byby.dev/uninstall-xcode#:%7E:text=Delete%20old%20simulators%20and%20devices,moving%20them%20to%20the%20Trash but all failed swiftui log.txt
6
0
278
Oct ’25
onContinueUserActivity(CSSearchableItemActionType, perform) does not work on a SwiftUI macOS app
onContinueUserActivity(CSSearchableItemActionType, perform) works as expected on iOS when we search and select an item from Spotlight, but nothing happens when we do the same on a SwiftUI macOS app. var body: some Scene { WindowGroup { MyView() .onContinueUserActivity(CSSearchableItemActionType, perform: handleSpotlight) } } func handleSpotlight(_ userActivity: NSUserActivity) { // Is not called... } How can we respond to a user clicking a Spotlight result from our apps on macOS?
3
0
880
Oct ’25
Customizable Toolbar on iPadOS26 seems not customizable
Hi, I have started app development fairly recently and I decided to develop for Apple due to the fact that my school uses iPads and they were so convincing that I decided to buy more Apple products adding to the experience with the iPad such as a Mac where I learned Xcode, Swift and SwiftUI as far as I could comprehend. I am working on a document based app for my school and I want to implement a toolbar that’s user customizable. There seems to be no way to get a customizable toolbar running on iPadOS26 though iPadOS16 has supported this feature and it has been till 18, I believe. I have set up a doc-based app in Xcode and that and all of its views do work except the toolbar that I added to my NavigationSplitView. The items show, when their defaultCustomization isn’t set to .hidden. The toolbar is given an id and the items are all wrapped in the ToolbarItem structure that also is given an id and the placement of .secondaryAction. The items show up and behave as expected in terms of grouping and making
1
0
150
Oct ’25
Reply to Complications not showing up after WatchOS 26
This doesn't seem to be a known bug. To be clear, is it that your complication had worked well on your device, and then disappeared after the device was updated to watchOS 26, or is it that you install your app and set up your complication on your device running watchOS 26, and the complication disappears soon after that? The former will be harder to debug because the issue only reproduces when the system is updated, and is likely related to complication migration. For the latter, you can try to reproduce the issue with the widget in this sample code. If you do reproduce, please share the steps, and I'll take a closer look. If your complication isn't based on SwiftUI + WidgetKit, it will be time to migration, as mentioned in this technote. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: General Tags:
Oct ’25
SwiftUI resultBuilder foreach
'm trying to write my own stack, and the issue I'm encountering is how to get the child content of a ForEach. // // ContentView.swift // test // // Created by cnsinda on 2025/10/18. // import SwiftUI public struct MyStack: View { var content: [Content] public init(@MyStackBuilder content: @escaping () -> [Content]) { self.content = content() } public var body: some View { VStack { // I expect to get 9, but it always returns 1. Text(count:(content.count)) } } } @resultBuilder public enum MyStackBuilder { static func buildBlock() -> [Value] { [] } public static func buildBlock(_ components: Value...) -> [Value] { components } public static func buildBlock(_ components: [Value]...) -> [Value] { components.flatMap { $0 } } // hit public static func buildExpression(_ expression: Value) -> [Value] { [expression] } public static func buildArray(_ components: [[Value]]) -> [Value] { components.flatMap { $0 } } static func buildFinalResult(_ components: [Value]) -> [Value] { components }
1
0
353
Oct ’25
AlarmKit alarm does not fire when device is active
I implemented AlarmKit framework to my app. It works fine when the device's screen is off. but it doesn't fire when the screen is on. No sound, No dynamic Island widget. what's wrong... is this just me? I tried other apps on appstore and they worked fine. maybe is it cause they were built with SwiftUI? I'm a flutter developer. just cause my app is non native could this happen... I'm so frustrated.
3
0
95
Oct ’25