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.
Search results for
SwiftUI List performance
50,597 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
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), ] //
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
Hello, I'm having some difficulties trying to customise a SwiftUI list-detail splitview using List and OutlineGroup: The model used is provided in Apple documentation OutlineGroup. The contentView is struct ContentView: View { @State var itemString = String() var body: some View { HSplitView { MyOutLine(title: MyOutLine, itemString: $itemString) .frame(width: 200, height: 300 , alignment: Alignment(horizontal: .leading, vertical: .top)) .padding() MyView(itemString: itemString) } } } The left view is struct MyOutLine: View { let title:String @Binding var itemString:String @State private var selection: FileItem? var body: some View { List(selection: $selection) { OutlineGroup(data, children: .children) { item in Text ((item.description)) .onTapGesture { selection = item itemString = item.description } .listRowBackground( selection == item ? Color.gray :nil ) } } .listStyle(.sidebar) .onAppear { itemString = No selection} } } The right view is: struct MyView: View { let itemS
Hi, Is there any way of changing the contentInset (UIKit variant) of a List in SwiftUI? I do not see any APIs for doing so, the closest I gotten is to use safeAreaInset . While visually that works the UX is broken as you can no longer scroll from the gap made by the .safeAreaInset(edge:alignment:spacing:content:) I have subbmited a feedback suggestion: FB16866956
Hi, I'm having a hard time trying to solve this impossibly small problem in SwiftUI. I have a list like this: struct ContentView: View { var body: some View { List { Button(action: { print(hello) }, label: { Text(Hello) }) } } } And every time I tap on it, the row deselect without animation, but I want the same effect as UITableView.deselectRow(at:animated:). Why is this so hard or am I missing something? I don't want to use NavigationLink because I only want to execute code upon tap, not navigating to other view, unless it's possible to only execute code using NavigationLink... Thanks,
Is there a way to optimize a List in SwiftUI? There is a problem with selection not working properly when the List has many rows. If you scroll to multi-select and up, some rows in the middle are not selected. I have an issue where selecting an unselected row deselects nearby rows. Is there any way for selection to work reliably even for a List of many rows? I would like to find a solution that is stable even when multiple lines are selected, like mail and note, which are the default apps in ios. ps. I am using CoreData. @State var selectedItem = Set() List(selection: $selectItem){ ForEach(items, id: .self){ item in ContactsRow(contactsData: item) } } .environment(.editMode, $editMode)
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.
I have been working on a feature, where I have a List in SwiftUI with previous and next data loading, user can scroll up and down to load previous/next page data. Recently, I faced one accessibility issue while testing voice-over, when user lands on the listing screen and swipe across the screen from navigation and when focus comes on list it should highlight the first item visible. But when user swipes back: Should it load the previous data and announce the previous item or it should go back to the navigation items? If it loads the previous item, what if the user wants to go to the navigation to switch to other actions and vice-versa? Did anyone come across this kind of issue? What can be the standard expected behavior in this case if list has both previous and next page scroll? I different tried gestures https://support.apple.com/en-in/guide/iphone/iph3e2e2281/ios, but it isn't working
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) } } }
<body><p>I've got a MacOS app and I want to be able to select a particular item in a List. Here's an outline of what I'm trying to do:import SwiftUIstruct SomeObject : Identifiable { let id = UUID() let name: String // lots of other stuff}struct ContentView: View { var someObjects: [SomeObject] @Binding var selectedObject: SomeObject var body: some View { List(someObjects, selection: $selectedObject) { someObject in Text(someObject.name) } } init(_ someObjects: [SomeObject]) { self.someObjects = someObjects }}I get the error Type of expression is ambiguous without more context on the Text initializer, with the n in someObject.name underlined in red.What does this error mean? If I remove the selection: from the List initializer and take out the @Binding line, it compiles fine.
Hello, I am creating a macOS app with SwiftUI and I added a sidebar with NavigationView and inside I added a List with NavigationLinks. I also added a separate NavigationLink at the bottom of the Window. The behavior I want to have is, when I press the NavigationLink at the bottom, then to deselect all the other NavigationLinks in the sidebar List. Most probably I still haven't properly understood SwiftUI and it's declarative paradigm yet, and I can't see a way to do this. Could someone help me? This is the code I have written: Enum enum Menu: String, CaseIterable { case library = Library case catalogue = Catalogue case filter = Filter } Main Code struct SplitView: View { var body: some View { NavigationView { VStack(alignment: .leading, spacing: nil) { MenuList() Divider() Spacer() NavigationLink(destination: FilterSpace()) { HStack { Text() Text(Filter) } .padding(5.0) .overlay(RoundedRectangle(cornerRadius: 10).stroke(Color.gray, lineWidth: 1)) } .cornerRadius(10) .pad
There seems to be a performance issue when scrolling using the track pad with SwiftUI scroll views in macOS 15. This issue is NOT present in macOS 14. When using the track pad the scrolling is not smooth, but stutters. However scrolling using the scroll bars is very smooth. The stuttering is worse if the SwiftUI ScrollView is in the detail view of a NavigationSplitView. The problem is not noticeable in scroll views with a small number views, but when the more views inside the scroll view, the more prominent the problem becomes. I have a simple example app that illustrates the problem here (the example app is a simplification of my app Yammixer): https://github.com/danwaltin/SwiftUIScrollViewPerformance When running this example app on macOS 14 (Sonoma) on an Intel i7 Mac book pro from 2019 the scrolling is buttery smooth. But on macOS 15 (Sequoia) on my Apple Silicon M1 Mac book pro the issue is very obvious. When using Instruments I see that on macOS 15 flame graph shows that 85% o
Topic:
UI Frameworks
SubTopic:
SwiftUI
I have a set of SwiftData objects, which include a thumbnail and also HD image data. I also have SwiftUI List, presenting, some information, including thumbnail image. The problem is, firstly, when I scroll, memory goes up and up, never seemingly releasing objects showed once. Secondly, it seems, it loads in the memory the whole object, including HD data, not only thumbnail. What can be the right way to work around here?