I have a list that allows deleting and moving. And there is an EditButton associated with the List : List { ForEach(conversions) { Text($0.line) } .onDelete(perform: deleteConversion) .onMove(perform: moveConversion) } When I swipe left one of the rows of the List, a red rectangular Delete button appears at the right edge of the row. Clicking it does nothing. If I click on the EditButton, each row gets a round - button on the left, and again clicking it does nothing. It's not all bad. If the left swipe on a row is taken far enough, deleteConversion gets called. And when the EditButton is pressed, the little 3-line grab handle appears at the right of each row allows the user to reorder the list.
Search results for
SwiftUI List performance
50,605 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
It appears that swift ui lists are broken on the Mac for complicated lists. I can't seem to do the following: Remove the spacing between lists using either default or plain styles. I always seem to get what looks like separator but it is near drawn? Can't remove the padding without hard coding values. Insets seem to be broken. The default highlight for self sizing cells seem to not highlight properly. To get around this I have moved to a LazyVStack but then you lose edit functionality of the list. I can write a simple sample later. Any one had any luck with lists on the Mac beyond a simple text item?
Has anyone else created a macOS SwiftUI app that uses a Table with a largish (~1000) number of entries? My app works OK at about 100 entries, but slows down as the number of entries increase. How slow? An instrumented test with 1219 entries shows a Hang of over 13 seconds from simply clicking/selecting an item in the table. Instruments says the time is mostly spent in _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION. Digging deeper I see AG::Subgraph::update(unsigned int) and descendants account for about half of the hang time. My app is using @Observable on macOS 14 and is being tested on an M2 Max Studio. There are other reported hangs. All seem to be in Swift/SwiftUI code.
How can i use a dictionary of type [SomeObject : [ValueObjects]]that belongs to viewModel(ObservableObject) to make a SwiftUI List using ForEach?
I want to display a simple message while waiting for a list to be populated. Something like Loading... and when the list starts being populated with even one item, remove the message, via a transition, and display the list. My current attempt, that does not work, looks like: struct JoinChannelView: View { @Binding var rooms: [ChannelInfo] @State var selectedRoom: String? var body: some View { VStack { if $rooms.isEmpty { Text(Loading...) .transition(.slide) } else { List(selection: $selectedRoom) { ForEach(rooms, id: .title) { room in Text(room.title) .font(.title) Text(room.description) .font(.subheadline) } .padding(.bottom) } } } .frame(width: 150, height: 300) } }
I've got a model with a bool variable that i'll need to bind with a SwiftUI Toggle that is displayed in a List.import SwiftUI struct MyModel : Identifiable { var id: String var name: String var notify: Bool }import SwiftUI struct ContentView : View { var myModels: [MyModel] = [] var body: some View { NavigationView { List(myModels) { myModel in Toggle(isOn: myModel.notify) { Text(myModel.name) } } .navigationBarTitle(Text(My Models)) } } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView(tickets: MyModel.mockModels) } } #endifWhen the user interacts with the toggle, i'll need the variable `notify` in the model to update.The only example that i've looked at that implements a Toggle is the WorkingWithUIControls - LandmarkList but i can't seem to get it to work with an array of MyModels.Any help would be much appreciated.
Hi, I'm creating a To-do list app with SwiftUI. There's a main 'List' view with all the lists users create. When you tap on a list, it takes you to the Detail View with the items in the list. The problem is, when I make a change to the list in the Detail View, it doesn't change in the main list. The changes are indeed getting saved, as if I restart the app, the changes are persistent. I've looked at similar issues but none of the solutions seem to be working. swift struct HomeView: View { @Environment(.managedObjectContext) var viewContext @FetchRequest(entity: ItemGroup().entity, sortDescriptors: [NSSortDescriptor(keyPath: ItemGroup.createdAt, ascending: false)]) var groups: FetchedResultsItemGroup var body: some View { NavigationView { List { Section { ForEach(groups, id: .self) { group in NavigationLink(destination: DetailView(group: .constant(group)), label: { GroupRow(group: group) }) // ... swift struct GroupRow: View { @Ob
I have a List. I want to disable first cell. How can I do it?I set .disabled(true) but it doesn't work. struct ContentView: View { var body: some View { List { ForEach(1..<5) { Text(($0)) .disabled($0 == 1) } } }}
Hello! We encountered a very intermittent crash with our application starting with devices running iOS 18.4. We have a screen that can display a long list of products in 2 states (expanded or collapsed) based off of a boolean if the user has interacted with that product yet. With this list, we very intermittently encounter a crash when we scroll like crazy up and down the list search the list quickly (search is performed each character change and list is filtered) Our project has iOS 17.0 as a minimum deployment target, and is Swift 6 enabled. Again, this started happening only with iOS 18.4, and is still visible (handful of occurrences each week). The crash report seems to be very internal to SwiftUI/Obj-c runtime. 5895AC17-6886-4070-BC80-8912E8394BDB.crash Any insights would be greatly appreciated!
Im trying to filter rows in the list that match what im looking for, I have added a filter form that toggles the following: parking x --Paid (true) o--free (false) o--street (false) Views o--forest (false) o--dunes (false) x--water (true) Traffic o--low traffic (false) o--moderate traffic (false) x--high traffic (true) Experience x--beginner (true) o--intermediate (false) o--expert (false) My goal is to have a filter that connects to some sort of list that ultimately returns the true options that specifically matches. Im extremely new and this is the code i copied from the tutorial for Landmarks List, but im trying to edit it. Sorry if its all over the place im new to coding. below is a link to the tutorial: https://developer.apple.com/tutorials/swiftui/composing-complex-interfaces struct FilterList: View { var landmark: Landmark @EnvironmentObject var landmarksVM: LandmarksViewModel @State private var showpaidOnly = false @State private var showfreeOnly = false @State priv
I have the following setup: Multiplatform SwiftUI App. When selecting a menu item from the sidebar, it opens correctly on the right side. When tapping something inside the List on the right side, the List disappears. Seems like a bug? When using a ScrollView on the Right side it works.
Hello, I have a list in the root view of my app like so: List { NavigationLink(destination: AnimalListView()) { SummaryView() } } And SummaryView is a row of boxes, like so: HStack { VStack { Text(24) Text(Dogs) } VStack { Text(10) Text(Cats) } // etc... } The root view is a count of each animal type. The detail view is a listing of animals, filterable by type. Can I make it so that if the user taps a specific box, it takes them to the detail view with the filter already set for the type in the box they tapped, but if they tap on the row itself, it goes there without the filter set? I can't figure out how to get the type or tap location from the summary view, up into the root view, to trigger a NavigationLink. Thank you
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?
I can't seem to figure out how to enable drag and drop on (selected) entries in a SwiftUI tree List (using the children) parameter in a macOS app. List(entries, id: .self, children: .children, selection: $selectedEntries, rowContent: { Row(entry: $0) }) Adding .onDrag (returning an NSItemProvider) to the list does nothing, adding it to a Row seems to cancel the selection gesture and is not really what I want as I would like to drag all selected rows at once. From what I could find, only the ForEach supports .onMove, but I cannot use the ForEach as this cannot be combined with the List's children parameter and I am not sure if that would allow me to drag anything outside the app's window. By now I am thinking of going back to NSOutlineView (or, worse, modify the one SwiftUI uses), so I really could use some help here. Thanks.
If I run this code below , it will goto the detail view the first time, but will not goto the detail view again. It locks up the program with no errors.If I add a second item in the first List (0..<2) it runs fine. Any ideas ?Xcode 11.3import SwiftUIstruct ContentView: View { var body: some View { NavigationView { List { NavigationLink(destination: DetailView() .navigationBarTitle(Test Detail)){ Text(Goto Detail).foregroundColor(.blue) } .navigationBarTitle(Welcome) } } }}struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() }}struct DetailView: View { var body: some View { List(0 ..< 5) { item in Text(hello).foregroundColor(.blue) } }}