Search results for

SwiftUI List performance

50,605 results found

Post

Replies

Boosts

Views

Activity

Reply to Allow custom tap gesture in List but maintain default selection gesture
can confirm this happens on iOS 17.2 as well. It seems like the issue is the lists built-in selection and swipe gestures interfere with any added custom gestures. I have tried using high priority gestures, simultaneous gestures and just regular gestures and none of them seem to allow BOTH the list and the custom gestures to work simultaneously. I have noticed this issue with quite a few of the UIKit backed swiftui features such as context menus, Lists, Forms, etc... Maybe it's time that SwiftUI started to get native SwiftUI implementations of these features.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
SwiftUI Tutorial: Building Lists and Navigation - [Cannot find 'coordinates' in scope] Error
I'm pretty new to SwiftUI, so I started the Apple tutorial and followed the steps pretty closely, but I have come across this error at step 7 that says Cannot find 'coordinates' in scope. I did a bit of searching and could not find anyone with the same problem, so I thought I'd post here. import Foundation import SwiftUI import CoreLocation struct Landmark: Hashable, Codable { var id: Int var name: String var park: String var state: String var description: String private var imageName: String var locationCoordinate: CLLocationCoordinate2D { CLLocationCoordinate2D( latitude: coordinates.latitude, longitude: coordinates.longitude) } var image: Image { Image(imageName) } struct Coordinates: Hashable, Codable { var latitude: Double var longitude: Double } } As far as I can tell, everything here is exactly as it is supposed to be. Could the tutorial be a different version of Xcode? Maybe this is a bug? I am not sure. If any of the other code from the project is relevant I can add that. Any help i
1
0
331
Aug ’23
Is it possible to scroll to item in SwiftUI List when the view appears on Apple Watch?
I have checked everything but this doesn't appear to work. Here is the part of the code used for that - simplified my view looks like this: ScrollViewReader { scroll in List(voices) { item in Button(item.title) { } .fontWeight(item.id == selected ? .bold : .regular) } .onAppear() { scroll.scrollTo(selected, anchor: .center) } } selected is properly shown as bold, so the value is proper. But the app doesn't scroll to it. I have tried various things like dispatching on main thread and even dispatching on main thread after 1 second, but nothing helps. However that scroll code works when being called from the Button. Is this a bug on watchOS?
2
0
817
Nov ’22
Video Player inside List SwiftUI iOS 16 - controls not displayed
Caught a strange situation. In iOS 16, the controls for the video player are not shown if the video player is placed inside the list. In iOS 15.6.1 this code works fine as it should. struct ContentView: View{ var body: some View{ VStack{ List(0..<2) { _ in VStack { let vp = AVPlayer(url: videoUrl) VideoPlayer(player: vp) .frame(maxWidth: .infinity, idealHeight: 320) .padding(.horizontal, -20) .onDisappear{vp.pause()} .padding() } } } } } Thank you all in advance
2
0
1.6k
Sep ’22
Reply to Unable to use transitions for SwiftData in List
The issue is triggered because of the use of SwiftUI List – If you simply comment out the list in your code, as shown below, the animation will work: //List() { ForEach(items, id: .self) { item in Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) .transition(.slide) // items do not slide in/out of view .onTapGesture { // called with 'withAnimation' -> no animation withAnimation(.easeIn(duration: 2)) { modelContext.delete(item) } } } .animation(.spring(duration: 3), value: items) //} SwiftUI List is supposed to automatically manage the animation of its items when they are inserted or deleted. I don’t see a good way that allows you to use SwiftUI List with your own animation. If that is important to your app, you might consider filing a feedback report (http://developer.apple.com/bug-reporting/) for SwiftUI folks to investigate – If you do so, please share your report ID for folks to track. Best, ——
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to List Sections
You have to create section headers. struct ContentView: View { var body: some View { List { Section(header: Text(Important tasks)) { TaskRow() TaskRow() TaskRow() } See details here: h t t p s : / / swiftuirecipes.com/blog/grouped-list-in-swiftui h t t p s : / / w w w.hackingwithswift.com/quick-start/swiftui/how-to-add-sections-to-a-list
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
SwiftUI: How to create a multiple timer app with a list of timers and how to jump between the timer views
I just created a timer app for me and my friends with multiple timers. To navigate between these timers i created a list for each timer in an array of timerObjects instanzes. struct ContentView: View { private let timers = [TimerObject(name: Kuchen, duration: 15), TimerObject(name: Atem anhalten, duration: 30), TimerObject(name: Abflug, duration: 7200)] var body: some View { NavigationView { List(timers, id: .id) { timer in NavigationLink { TimerView(timerObject: timer) } label: { Text(timer.name) } } } } } The TimerView() is just the view that handels and present the whole thing behind the timer. My Problem now is now: if i start a timer in the TimerView() and than go back to the list and than go back to the started timer, i get a new instanz of my timer and the TimerView() don´t show me the started timer. My goal is to go back to the started timer! To clarify my problem, I also recorded my problem once and uploaded it to youtube so that you can see it too: https://youtu.be/bdh-122
0
0
881
Jan ’22
Reply to SwiftUI List performane
My guess is your problem is that you are trying to filter the list directly or the array you pass to the list. Which leads to to whole thing being a big performance hog. Maybe try what Apple themselves showed in their WWDC videos: do not pass your array to „List(array){}“, instead create a List without passing anything „List{}“ and then inside the brackets do a for each with your array, where yo decide via classic SwiftUI „if“ when to render certain elements. This gives you multiple benefits and seems the be the recommended way in case you want to modify list content based on certain States. Apple used this method in their tutorials, to filter favorite items in a list if I remember correctly.Update: Ok, I made small test yesterday and this approach also didnt work. Will keep an eye on this in case soem solution comes into my mindUpdate 3: A collegue found a simple solution:Instead of a complicated workaround, just empty the List
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’19
Reply to UIScrollView does not give touches to subview if drag starts quickly
My problem was caused by something dumb that I left out of my question, because I was trying to simplify it to post here. My UIScrollView was actually inside a SwiftUI view hierarchy, using UIViewRepresentable. Higher in that view hierarchy, there was a SwiftUI List, which also has scrolling. I had forgotten about that List because I was using it for it's layout appearance, grouping items into sections, but not for its scrolling. Once I got rid of that List, everything worked as expected.
Topic: UI Frameworks SubTopic: UIKit Tags:
Feb ’22
Performance issue
What I'm trying to do. I am trying to upload the macOS app to App Store. Issue. I got a reject due to performance issue. This is the message I received. Guideline 2.1 - Performance We discovered one or more bugs in your app when reviewed on Mac running macOS 10.15.6. Specifically, the app does not appear to be listed in the Accessibility page. They also sent me a screenshot for the issue. From what I understand, it looks like they want the app to be listed in System Preferences > Security & Privacy > Privacy > Accessibility so they can just simply click the checkbox to enable accessibility for the app. What I did. (1) Find related documentation on Apple developer site. I was not able to find any related sources to solve how to add the app in the list. There were documents for camera / mic access but not for accessibility. (2) Added some code to show an alert to help user how to enable accessibility for the app. Function that check if keyboard access is
1
0
383
Aug ’20