SwiftUI List performance

39,584 results found

Post marked as solved
1 Replies
1.4k Views
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
Posted
by
Post marked as solved
3 Replies
737 Views
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 ?
Posted
by
Post not yet marked as solved
3 Replies
2.1k Views
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) }
Posted
by
Post not yet marked as solved
1 Replies
674 Views
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) } } } }
Posted
by
Post not yet marked as solved
1 Replies
1k Views
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
Posted
by
Post not yet marked as solved
3 Replies
4.3k Views
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!
Posted
by
Post not yet marked as solved
0 Replies
569 Views
Speaking about Outlines (9:22). I want to declare some action for tap on each row from the List, no matter of depth level of the tree. If to add .onTapGesture(perform:) to the Label or GraphicsRow instance, looks like it will override the system logic and therefore items will not expand/collapse while tapping on them. Instead only my custom action will be performed. The only way to collapse/expand, is to tap outside the GraphicsRow View. That leads to bad UX. I do understand why it happens and clearly see the structure of generated views using Debug View Hierarchy, but... Is there any possibility to achieve perform custom actions when user tap on List rows and at the same time to keep items expanding/collapsing as usual?
Posted
by
Post not yet marked as solved
1 Replies
463 Views
Is there a SwiftUI equivalent of UIKit's UIAccessibilityPostNotification with .announcement? I have a SwiftUI screen with a TextField acting as a search input, and a List of matching results for the current text field content below it. The process of obtaining matching results for the term entered in the text field is asynchronous (goes over a network). How can I alert VoiceOver users when the list updates? I don't really want to programmatically shift their focus, I'd normally post a suitable accessibility notification in UIKit for this.
Posted
by
Post not yet marked as solved
27 Replies
18k Views
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.
Posted
by
Post not yet marked as solved
4 Replies
1.1k Views
In SwiftUI 3, I used to be able to customize the spacing between sections using this: init() { UITableView.appearance().sectionFooterHeight = 0 UITableView.appearance().sectionHeaderTopPadding = 0 UITableView.appearance().sectionHeaderHeight = 8 } I need these sections because it's the only way to have swipe actions rendered with rounded corners (FB10233033). While this solution isn't ideal, it's the only way to use the native swipe actions and have this type of cells: On SwiftUI 4, Lists are now using UICollectionView and the code in the custom initializer doesn't work anymore.
Posted
by
Post not yet marked as solved
6 Replies
3.0k Views
I have a simple SwiftUI project, when I click the any list items, I want to route different SwiftUI. Below, I used arrays, and for every SwiftUI, I want to use [0], [1],..., but it throw error, I do not know why? Any idea? ContentView: import SwiftUI struct ContentView: View { var body: some View { NavigationView { List(contacts) { contact in NavigationLink(destination: NumberOneView(contact: contact)) { ContactRow(contact: contact) } } .navigationBarTitle(Contacts) } .environment(.colorScheme, .light) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct ContactRow: View { let contact: Settings var body: some View { HStack { Image(contact.imageName) .resizable() .aspectRatio(contentMode: .fill) .frame(width: 20, height: 20) VStack(alignment: .leading) { Text(contact.name) .font(.system(size: 21, weight: .medium, design: .default)) } } } } Settings.swift: import Foundation import SwiftUI struc
Posted
by
Post not yet marked as solved
1 Replies
177 Views
I found a bug in SwiftUI's List view where if the listRowBackground is set, the items will sometimes be opaque while dragging to reorder (instead of the default transparent views). Has anyone else encountered this or found any work-arounds for it? I'm currently using Xcode 15 and iOS 17, and the issue is reproducible, as long as you are patient, since it is very sporadic. Here is the code for the reproducible example: struct ContentView: View { @State private var editMode: EditMode = .inactive var body: some View { VStack { Button(editMode == .active ? Done : Edit) { if editMode == .active { editMode = .inactive } else { editMode = .active } } List { ForEach(1 ..< 11) { index in Text(Item Number (index)) } .onMove(perform: { _, _ in }) .listRowBackground(Color.white) } .environment(.editMode, $editMode) } } }
Posted
by
Post not yet marked as solved
1 Replies
7.3k Views
How to remove the spacing between List plain style section in swiftui iOS 15 struct ContentView: View { var body: some View { List { Section { Text(Hello, World!) Text(Hello, World!) Text(Hello, World!) } Section { Text(Hello, World!) } Section { Text(Hello, World!) Text(Hello, World!) } header: { Text(section) } }.listStyle(.plain) } }
Posted
by
Post not yet marked as solved
0 Replies
388 Views
Hello there, I try to delete rows by onDelete(perform:) modifier in expandable list in swiftUI and embed EditButton() So user can change the order of items in the List, here is my code for View : language import SwiftUI struct ContentView: View { var body: some View { NavigationView { VStack { List(sampleMenuItems, children: .subMenuItems) { item in HStack { Text(item.name) .font(.system(.title3, design: .rounded)) .bold() } } } .listStyle(InsetGroupedListStyle()) .navigationTitle(List) .navigationBarItems(trailing: Button(action: {}) { EditButton() } ) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } and Data Model: language import Foundation struct MenuItem: Identifiable,Hashable { var id = UUID() var name: String var subMenuItems: [MenuItem]? } let sampleMenuItems = [ MenuItem(name: iphone model, subMenuItems: iphoneModelItems), MenuItem(name: ipad model, subMenuItems: ipadModelItems), ] //
Posted
by
Post marked as solved
1 Replies
579 Views
I am building a list in SwiftUI. In my view, I want the 'Jesse Lingard' and 'Manchester United' text to be next to the image but they are appearing underneath. How do I fix this?
Posted
by