Search results for

SwiftUI List performance

50,616 results found

Post

Replies

Boosts

Views

Activity

Reply to Custom @Observable RandomAcccessCollection List/ForEach issues
Ultimately you do need to use a data structure that provides you with collections of identifiable elements. If you're down the path of using a custom data type, for example ExpModel, you'll a IndexedIdentifierCollection. And using an Array in the view body has its performance issues because every time the body is evaluated a whole new array is being allocated. I recommend you review Demystify SwiftUI performance - WWDC23 - Videos - Apple Developer. It covers this topics.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Is 'List' unsupported in Widgets?
The following code, in an independent project works fine: struct ContentView: View { var body: some View { List { Text(Hello, world!) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } The following code in a Widget Extension results in an error being displayed in the SwiftUI view (it builds fine): struct ContentView: View { var body: some View { List { Text(Hello, World!) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .previewContext(WidgetPreviewContext(family: .systemMedium)) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().previewContext(WidgetPreviewContext(family: .systemMedium)) } }
0
0
720
Aug ’20
Reply to Is it possible to delete an item from Coredata using onTapGesture?
hi, the .onDelete modifier is usually something you add to a ForEach, as in List { tForEach(items) { item in ttText(item.name) t} tt.onDelete(perform: yourDeleteFunction) } the .onTapGesture is something you would add to a view associated with an item in the list, within the scope of the ForEach: List { tForEach(items) { item in ttText(item.name) ttt.onTapGesture({ doSomething(to: item) }) // doSomething could certainly delete this item t} } (i think that's right and) hope that helps, DMG
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’20
SCNAudioPlayer performance issue
Hi!I am trying to add SCNAudioPlayer to my node that represent monster in the Scene, so I want play positional audio, such monster can be more than 1 etc(1-10) objects, so I clone root node of this monster and add AudioPlayer for each cloned node, but at this time I receive a huge performance issue that my frame rate decries from 60 to 30 frames/sec.Than I found one way that I can share 1 instance of SCNAudioSouce between all my copies, like it posible with geometry, but its not working for me, because SCNAudioPlayer added only to 1 node from 10 that I cloned.Source code:private lazy var _beeMinion: SCNReferenceNode = { if let filePath = Bundle.main.path(forResource: Bee Enemy, ofType: scn, inDirectory: art.scnassets), let refereceNode = SCNReferenceNode(url: URL(fileURLWithPath: filePath)) { return refereceNode } print(Node not loaded !!!) abort() }() var beeMinion: SCNReferenceNode { if !_beeMinion.isLoaded { _beeMinion.load() AudioEngine.instance.actionSoundPlayer?.play3DSound(.BeeMinion, node: _b
0
0
499
Sep ’17
VTCompressionSessionEncodeFrame performance decrease
Our team use videotool box to do hardware-accelerated decoding and encoding. From iphone 6 to 7 plus, the performance of encoding increases, and it takes less time to transcode a video. However, the time spent on VTCompressionSessionEncodeFrame increases drastically on iphone 8 and newer models. For example, it takes about 650 us to encode a 720p frame on iphone 8 but 4100 us on iphone xs max. The other problem is, when i compare our app to a simple video recording app (both encode in 1080p), the time we spent on VTCompressionSessionEncodeFrame is almost 8 times as the recoding app. Is this normal?
2
0
1k
Jan ’20
Reply to How to embed List in ScrollView using SwiftUI
Notes has a Recently Deleted folder view that shows a search field and some captions above the list. The whole vertical stack is scrollable. That makes me think they're using UIKit and not SwiftUI. Video Using ForEach with a Divider won't allow .swipeActions to work, as it must be inside a List.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21
AppIntent perform method not called.
We have a widget bundle with multiple widgets. I'm adding a widget that is interactive (iOS 17 and higher). Our widget code is in a static library that gets linked into the widget extension target in our main app Xcode project. I have SwiftUI buttons constructed with the intent constructor in our UI See https://developer.apple.com/documentation/swiftui/button/init(intent:label:) When I press the button the timeline refreshes (conforming to TimelineProvider) but the perform method doesn't seem to be called. I've seen multiple pieces of advice and none of them seem to work. I've tried on a physical device and a simulator. I've tried adding an AppIntentsPackage. I've tried including the AppIntent code in the app and the widget. I've tried setting the openAppWhenRun to true and false and not setting it at all. I've tried simplifying the intent to just printing out a line to the console and returning a result. At this point I have no idea how to debug this and I don't know what else to t
4
0
357
Mar ’25
change binding of List with button press
Hi, I'm new to swiftUI and am having a few issues getting my head around how it works. My immediate issue is that I'm getting a response from an api in the form of a JSON string that I'm splitting into 2 arrays of my data model. This works fine and I have 2 lists in my view that if I change the binding in my list, the data changes to the other list. I can't seem to get it to change on a button click though. I want 2 buttons (one for each list) and clicking them will change the binding. I've got to the stage where I feel I'm soooooo close, but am missing something obvious. This is the code in my view: struct SplitView: View { @EnvironmentObject var viewRouter: ViewRouter @State var list1 = [MyModel]() @State var list2 = [MyModel]() private var viewingModels: [MyModel] { list1 } var body: some View { HStack { Button(action: { //selected = 1 }){ Text(List 1) } Button(action: { //selected = 2 }){ Text(List 2) } } List(viewingModels, id: .ID)
2
0
690
Feb ’21
Reply to custom-URL-handling method not being called
To receive a Universal Link, use the onOpenURL(perform:) modifier on your root view and you can use [.handlesExternalEvents] (https://developer.apple.com/documentation/swiftui/scene/handlesexternalevents(matching:)) modifier to specify the external events that the view’s scene handles if the scene is already open.
Topic: UI Frameworks SubTopic: General Tags:
Apr ’25
Reply to What is the best and simple way to link a SwiftUI button action to a View Model?
This import SwiftUI import Combine struct ContentView: View { @State private var isPresented = false var body: some View { Button(Show Modal with full screen) { self.isPresented.toggle() } .fullScreenCover(isPresented: $isPresented, content: VideoList.init) } } struct VideoList: View { @Environment(.presentationMode) var presentationMode @ObservedObject private(set) var viewModel: ViewModel @State private var isRefreshing = false var body: some View { NavigationView { List(viewModel.videos.sorted { $0.id > $1.id}, id: .id) { video in NavigationLink( destination: VideoDetails(viewModel: VideoDetails.ViewModel(video: video))) { VideoRow(video: video) } } .onPullToRefresh(isRefreshing: $isRefreshing, perform: { self.viewModel.fetchVideos() }) .onReceive(viewModel.$videos, perform: { _ in self.isRefreshing = false }) .navigationBarTitle(viewModel.navigationBarTitle) } .onAppear(perform: viewModel.fetchVideos) .frame(maxWidth: .infinity, maxHeight: .infinity) .backgr
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’20
Reply to Xcode 16 - List Lazy loading broken
Hello I don't know if I arrive to late to the party but be aware that Apple has introduce a new settings that does some optimisation for previews but potentially breaks List lazy loading in debug. Basically since Xcode 16, Apple introduced a new execution engine for Previews with 30% improvements between edits and rendered previews. More technically, it does type erasing by wrapping your SwiftUI Views to AnyViews. Only in DEBUG. So this also comes at the cost of making your code less performant at runtime (besides breaking some List lazy loading optimization and others). But the other annoying thing is that you might get completely different behaviour between RELEASE/DEBUG where some code could be working fine in DEBUG but not being re-rendered when it should, and thus completely buggy in RELEASE... To turn this off, you can set this in your project (Build Settings for your target, Add User-Defined Setting) SWIFT_ENABLE_OPAQUE_TYPE_ERASURE=NO Don't know if this will help bu
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24
Performance - App Completeness
I am trying to publish your application on me, but I am facing a problem in reviewing the application Note that the application works efficiently without any problems on my device. Performance - App Completeness : an internet error message when we launched the app. Issue Description The app exhibited one or more bugs that would negatively impact App Store users. Bug description: an internet error message when we launched the app. Review device details: Device type: iPad Air (5th generation) and iPhone 13 mini OS version: iOS 17.6 app link (TestFlight) : https://testflight.apple.com/join/5HvH2sk1
0
0
446
Aug ’24
AVAudioPlayerNode.play() performance
While investigating some performance issues in my game app I found that AVAudioPlayerNode.play() is taking a long time to complete, sometimes close to 20 milliseconds (more than the time allotted for a single frame at 60 FPS).Currently I'm disconnecting and reconnecting player nodes with each play event to ensure they're connected with the proper format for the sound being played. Below is some example code (it uses Xcode's iOS game template and replaces the code in GameViewController.swift):import AVFoundation import GLKit import OpenGLES import QuartzCore final class GameViewController: GLKViewController { private let engine = AVAudioEngine() private let player = AVAudioPlayerNode() private var context: EAGLContext? private var buffer: AVAudioPCMBuffer? override func viewDidLoad() { // General set up. super.viewDidLoad() context = EAGLContext(api: .openGLES2) let view = self.view as! GLKView view.context = context! // Load audio buffer. let path = Bundle.main.path(forResource: test.wav, ofType: nil
3
0
3.4k
Nov ’16