SwiftUI List performance

39,501 results found

Post not yet marked as solved
3 Replies
4.7k Views
SwiftUI performance is much slower on macOS than on iOS. macOS running SwiftUI is even slower than the iOS simulator. As a simple example, create a List with a few hundred rows (anything over 100 gets pretty bad). macOS scrolling gets unacceptably slow. This is made even worse if the rows have interactive items like Slider or TextField (think a medium complexity inspector). Take the same exact code and Build and Run on iOS and it feels much smoother. Is this an issue with the Window Server? I keep hearing from Apple that SwiftUI is the future of UI for Apple Platforms. And I believe you. But we’ve been waiting a year for performance improvements so that we can seriously consider SwiftUI in our new products and they haven’t come to macOS. Can we expect to see a fix? If SwiftUI isn’t the right framework for multi-platform pro applications (image rendering/editing) then what is? Note that using Equatable helps stop the entire view from recom
Post not yet marked as solved
0 Replies
252 Views
This is a question I've been dealing with and don't know whether or not it is intended or being worked on atm. Basically I've found that when you append items to a List that triggers the List to immediately re-evaluate all pre-existing items in the List (unnecessarily). While re-evaluation as I'm told is not really that expensive if the List has 1000 items there is still a decent amount of overhead that this cause. Am I using List the wrong way or is Apple working on optimizing aspects of SwiftUI like this?
Posted
by
Post not yet marked as solved
0 Replies
1.1k Views
I'm having issues with the scrolling performance in my app. I use CloudKit to store a list of Items. I access these Items with @FetchRequest var items : FetchedResults I created a List with a ForEach inside to iterate over the items and pass them to a ChecklistItemView. The ChecklistItemView accesses the Item as an @ObservedObject. This all works fine and I am able to edit the items with the Textfields but the performance when scrolling is very bad. On my iPhone 12 mini I get light stuttering and on my older iPad pro it gets very bad. Interestingly everything is smooth when the item is just displayed with Text(). My guess is that the Textfields update the item during binding when the TextField appears on screen. This is updating the whole list of items then triggering a redraw of all Textfields, resulting in a stuttering scrolling experience, because the view is redrawn again and again. It does not get worse with longer list. It is enough to fill the scree
Posted
by
Post not yet marked as solved
0 Replies
476 Views
I got a problem here. I made two List and both Lists have 'onMove()' function. I expected that if I start to drag a component in the List, it can only be droppable in the List which I started drag. However, the component can be dragged to another List and when the component dropped, it shows an error. It is the only bug in the project with macOS target SwiftUI project. Not in ios target. Is there anybody who has an answer?
Posted
by
Post not yet marked as solved
2 Replies
445 Views
I have quite a bit of material about SwiftUI Lists. However, I seem to be lacking information about how to respond to an item being selected. I put selected into quotes because my idea of selecting an item is different from putting a list into selection mode. For example, in the book SwiftUI for Masterminds discusses in Chapter 10 about presenting a selection tool when a List is initialized with the selection attribute. The selection tool presents checkboxes (circles actually) that allow the user to select one or more items in the list. This type of selection is not what I am thinking about. When I refer to selecting an item I mean tapping or clicking (on a Mac) an item. This action fires an event that the application responds to. This is not necessarily a navigation event. It might be that the appropriate response is send a message to a remote site or to perform a calculation using the item that was tapped or clicked. Thus, the complexity of navi
Posted
by
Post not yet marked as solved
1 Replies
1.6k Views
I have a SwiftUI List with multiple Sections. Now I want to to move and delete whole Sections without but not the items within the section. Currently I am doing the following: swift List { ForEach(items) { item in Section(header: Text(item.name)) { Group { NavigationLink(Item List, destination: ContentListView(item: item)) } .deleteDisabled(true) .moveDisabled(true) } } .onMove(perform: { indexSet, destination in items.move(fromOffsets: indexSet, toOffset: destination) }) .onDelete(perform: { indexSet in items.remove(atOffsets: indexSet) }) } .listStyle(SidebarListStyle()) but with this I can not change anything. Is this even possible with standard SwiftUI?
Posted
by
Post marked as solved
2 Replies
702 Views
Hello, I am having an issue at the moment. I noticed for iOS 15 when you have made a list using SwiftUI, VoiceOver would describe which cell is being moved to adjacent to it. Now with iOS 16 it VoiceOver doesn't say anything while being moved up or down. Here is a sample code of what I am speaking of. struct SampleView: View { let alphabetArray = [a, b, c, d, e, f] var body: some View { List { ForEach(alphabetArray, id: .self) { letter in Text(verbatim: letter) } .onMove(perform: move) } .environment(.editMode, .constant(.active)) } private func move(from source: IndexSet, to destination: Int) { } }
Posted
by
Post marked as solved
17 Replies
11k Views
I have a performance issue with List when I have a large amount of data that is replaced. Given the code below, a data set of about 3500 name items are loaded from a fetch request. Depending of the selected gender in the segmented picker these items are filtered and the displayed in the List. When the List first render I have no performance issue with the loading and rendering of items. It scrolls nicely and smoothly through 1700 items. But as soon as I switch gender through the segemented picker it takes about 30-45 seconds to render the List again.I think this has to do with removing 1700 items and the inserting 1500 items again from the List. Is there a best practice how to reload a large amount of items in SwiftUI? Or can I reset the List before I load it again, since there is no issue initially.Anyone else having issue same issue?struct NameList: View { @ObservedObject fileprivate var global = GlobalSettings() @FetchRequest(
Posted
by
Post not yet marked as solved
3 Replies
2.4k Views
Hi I am developing an app with swiftUI. Here is the code of a map view. I create customized annotations and show them on the map view. The issue is that when I drag or zoom in/ out on the map view. The app is so slow. The fps decrease to about 20 - 30 from 60. I use instruments to analyze this app. The result shows that there are thousands of times annotation render. I think that the reason for this issue may be off-screen rendering. But I don't know how to solve it. Looking forward to your help. swift Map(coordinateRegion: $region, interactionModes: .all, showsUserLocation: true, userTrackingMode: $trackingMode, annotationItems: result, annotationContent: { mark in MapAnnotation(coordinate: CLLocationCoordinate2D(latitude: mark.lat, longitude: mark.long)) { Button {withAnimation { self.selectedGymUid = Int(mark.uid) }} label: {RoundedGymIconOnMapView(name:mark.name) .clipShape(Circle()) .overlay(Circle().stroke(selectedGymUid == Int(mark.uid) ? Color(.green).opacity(0.5) : AppColor.shared.joggingCol
Posted
by
Post not yet marked as solved
1 Replies
925 Views
I am trying to recreate the stock Reminders app in SwiftUI. However, looking at the top 2x2 grid and then the account-based sectioned list of reminder lists, it seems nearly impossible to replicate as the sectioned list must essentially be a subview of a scrollView with the grid as another subview above it as the grid scrolls alongside the list of lists. Having the grid as an element in the list works, but has the row separators. Having a scrollView that has the Grid and then a List as children makes the list have a height of 0. Any thoughts?
Posted
by
Post not yet marked as solved
0 Replies
147 Views
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?
Posted
by
Post not yet marked as solved
2 Replies
791 Views
I am developing an application that allows users to create recipes. The recipes can only contain ingredients from a pre-selected list. I'm looking for something where, when I select a text field, a list pops up and, when I select an item in that list, it will dismiss the list view and populate the text field with the item that was selected. Does something like this exist natively in SwiftUI or in some 3rd party library?
Posted
by
Tee
Post not yet marked as solved
3 Replies
333 Views
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
Posted
by
Post not yet marked as solved
1 Replies
4.5k Views
Hi folks, I am new to SwiftUI. I've got the following small code. All I want is to refresh the List after pull-to-refresh. Is there any reloadData ? Thanks in advance! import SwiftUI import SwiftUIRefresh struct ContentViewFavorite: View { let posts = Data.posts() @State private var isShowing = false var body: some View { List { ForEach(posts) { post in PostViewFavorite(post: post) }.padding(.all, 20) }.pullToRefresh(isShowing: $isShowing) { self.isShowing = false } } } struct ContentViewFavorite_Previews: PreviewProvider { static var previews: some View { ContentViewFavorite() } }
Posted
by