https://gist.github.com/vanvoorden/1c7c6ed08898de7f4b8619147537c0eb Hi! Has anyone here seen weird performance problems when passing values from a Collections.OrderedDictionary to a SwiftUI.List inside SwiftUI.NavigationStack? I see some performance problems that go away when switching back to SwiftUI.NavigationView. At this point, I'm not sure if it's a problem in the OrderedDictionary implementation or not. Anyone want to take a look and see if you can help track this down? For a simple backing store to drive a simple SwiftUI app displaying a List of data, the OrderedDictionary (from swift-collections) has the advantage of giving us the option to access (by an arbitrary key) in constant time. The OrderedDictionary exposes a values property that conforms to RandomAccessCollection. Since we can pass a RandomAccessCollection as data to generate a List, we should hope to be able to pass the OrderedDictionary.values the same way we would pass an Array. This is leading
Search results for
SwiftUI List performance
50,597 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi there, I'm learning SwiftUI now it seems interesting (it was before, but more this year ^^). I try to understand why as soon as I add navigationBarItems into my NavigationView, SwiftUI transform my list into a grouped cell. Also, I follow the code shown in Introduction to SwiftUI session this Tuesday and it seems that toolbar is really a toolbar instead of putting everything on navigation bar like it shown. Is anyone get the same result ?
I study SwiftUI in swift tutorial. In tutorial Apple shows that code: List(landmarks,id: .id){ landmark in LandmarkRow(landmark: landmark) } Where landmarks it is array of Landmark, id it is String var in structure Landmark . What do parameter id: .id?
Is there any list of actions to perform in System Events of AppleScript?
As SwiftUI adoption grows, developers face challenges in effectively measuring and optimizing SwiftUI app performance within automated tests. Currently, the only viable approach to analyzing SwiftUI performance is through Profiling (Instruments), which, while powerful, lacks the ability to be incorporated into automated testing workflows. It would be incredibly valuable if XCTest could introduce new performance metrics specifically tailored for SwiftUI, allowing us to write tests against common performance bottlenecks. Suggested Metrics: View Body Evaluation Count – Tracks how often a SwiftUI body is recomputed to detect unnecessary re-renders. Slow View Bodies – Flags SwiftUI views that take a significant amount of time to compute their body. These metrics would help developers identify inefficiencies early, enforce performance best practices through CI/CD pipelines, and ensure a smooth user experience. I belie
SwiftUI List Accessibility VoiceOver
Topic:
Safari & Web
SubTopic:
General
Hi, There seems to be a performance issue or bug with NavigationLinks in a List, whenever the user scrolls fast over multiple rows over. Without a NavigationLink, the below example prints the indices in the console in right order, however, with a NavigationLink, the indices are not updated correctly, and e.g. fast scrolling from row 20 to 70 doesn't update any value. More specifically, this is an issue with List rows using AsyncImage with placeholders, where the list doesn't update the specified row, and therefore still shows the placeholder image. To then update the image, the user has to interact anywhere on the screen. I am using the newest XCode version and am using iOS 16. I can replicate it in the Simulator as well as on my iPhone. NavigationStack { List(0...100, id: .self) { index in NavigationLink(value: index) { Text(index.description) .onAppear { let _ = print(index, appearing) } .onDisappear { let _ = print(index, disappearing) } } } }
Has anyone used the new SwiftUI 2.0 TextEditor with a sizeable string? I'm currently trying it with a 400K text string and typing into the TextEditor horribly slow. Each letter I type takes seconds to appear. When the text size is small (say just a few thousand characters) it's fast - so it's clearly something to do with performance. Is this a known issue? Should I be doing something to improve it? PS - I do need to use it for my app (for e.g., a Markdown editor that loads a large file) if let t = try? String(contentsOfFile: filePathName, encoding: .utf8) { editorText = t Config.logger.debug(EditorView.onAppear: Read text count = (t.count) characters) }
In SwiftUI, it is recommended not to store ViewBuilder closures in sub-views but instead evaluate them directly in init and store the result (example: https://www.youtube.com/watch?v=yXAQTIKR8fk). That has the advantage, as I understand it, that the closure doesn't need to be re-evaluated on every layout pass. On the other side, identity is a very important topic in SwiftUI to get the UI working properly. Now I have this generic view I'm using with a closure which is displayed in two places (HStack & VStack). Should I store the closure result and get the performance improvements, or evaluate it in place and get correct identities (if that is even an issue)? Simplified example: struct DynamicStack: View { @ViewBuilder var content: () -> Content var body: some View { ViewThatFits(in: .horizontal) { HStack { content() } VStack { content() } } } } vs struct DynamicStack: View { @ViewBuilder var content: Content var body: some View { ViewThatFits(in: .horizontal) { HStack { conten
Hello I don't know why but when I put a List before my ForEach loop, all the text disappears Code: // import SwiftUI struct SearchDetailView: View { var sf: SF var body: some View { ScrollView{ ForEach(sf.items, id: .self) { item in HStack{ Image(systemName: item) Text(item) } } .navigationTitle(sf.title) } } } Thank you for your time
Hi, How to hide the Chevron icon from a list rows in SwiftUI ? Kindest Regards
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi, is it possible to disable scrolling behavior in the SwiftUI List view? I'd like to take advantage of the new grouping features List(content, children: .children) in List and want the list to be part of a larger scrolling view. As it stands I get an embedded scroll view for the list which is not my intent. Thanks!
What have I done wrong? I am trying to List a set of string values from an array, I spent all day trying to get it to work. What have I done wrong? import SwiftUI struct ContentView: View { @State private var menuItems = [Settings, Readings Entry, Food Diary] @State private var targets = [Settings(), ReadingsEntry(), FoodDiary()] var body: some View { NavigationStack { List { ForEach(menuItems) { menuLine in print(menuLine) } }.navigationTitle(Menu) } } } The latest set of Error messages are: Against the ForEach Line : Cannot convert value of type '[String]' to expected argument type 'Range' Against the print line3: Type '()' cannot conform to 'View'
I have a swiftUI listView. Each row includes details about a model object, and a button to perform a specific action in the row. struct EpisodeRowView: View { @ObservedObject var episode: Episode var body: some View { HStack { if shouldShowRightButton() { Button(action: { self.handleRightButtonTap() }) { rightButtonImage() } .padding(.horizontal) } NavigationLink(destination: EpisodeDetailView(episode: episode)) { Text(episode.title) } } } Unfortunately when I tap the button it performs the push to the navigation destination. Is there some way I can prevent/disable this unwanted push? thanks, Mike
How do I hide the separation lines inside Lists in SwiftUI for iOS 14? Previously I could use UITableView.appearance().separatorStyle = .none but this doesn't seem to work anymore.