I am trying to display a SKScene inside a SwiftUI list but I'm having problems getting it to size properly. Here is the code I'm using: struct MyView: View { var scene: SKScene // this is a SKScene with .aspectFit scaling mode var body: some View { List { Section { GeometryReader { geo in SpriteView(scene: scene, options: [.allowTransparency]) .frame(height: geo.size.width / scene.size.width * scene.size.height) } } Section { Text(SomeOtherStuff) } } } } Doing this scales the actual SKScene properly but the list 'cell' doesn't stretch to fit the scene it contains, therefore clipping chunks of said scene. If I drop the GeometryReader and hard code the height, the cell resizes. My guess is that the SKScene dimensions are not yet available to SwiftUI when the GeometryReader is evaluated. Any suggestions?
Search results for
SwiftUI List performance
50,611 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is there any performance benefit to using UIImage.prepareForDisplay() or its related methods when using Image(uiImage:)?
@lehrtim No. The issue is unresolved. I had hoped that macOS 26 would prove better—especially since the WWDC sessions called out massive improvements in Table performance for large data sets, but that appears to be vaporware. I see far worse performance on 15.5 and 26 than I did on macOS 15.4. Unfortunately, the best advice I can offer is: stay away from SwiftUI Table. Use AppKit and NSTableView directly.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Usually, it is advised to replace by List, but that does not fit all the needs.Did you see this:h ttps://dev.to/hugh_jeremy/adding-an-nstableview-to-a-swiftui-view-212p
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I have the following lines of code to work with a list of strings. import SwiftUI struct ContentView: View { @State private var users = [George, Kenny, Susan, Natalie] var body: some View { NavigationView { List { ForEach(users, id: .self) { user in Text(user) } .onDelete(perform: delete) } .navigationBarTitle(My family) .toolbar { EditButton() } } } func delete(at offsets: IndexSet) { users.remove(atOffsets: offsets) } } Now, I'm doing the following out of curiosity. Now, I have a button in naviationBarItems. And I wonder if I can turn on and off the edit feature of the list with the button? struct ContentView: View { @State private var users = [George, Kenny, Susan, Natalie] var body: some View { NavigationView { List { ForEach(users, id: .self) { user in Text(user) } } .navigationBarTitle(My family) .navigationBarItems(trailing: Button(action: { print(Edit button pressed...) }) { Text(Edit) } ) } } } Muchos thankos.
Which version of XCode ?I do not see any deprecation information.Seems you followed exactly this tutorialh ttps://developer.apple.com/tutorials/swiftui/building-lists-and-navigationDid you check your import ?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi, so I have been learning SwiftUI and writing an app. I have found out that the following code won't compile and neither Xcode shows the preview of that view. Instead Xcode will display this error message when I try to preview it: Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project Just to demonstrate this issue, all MVVM code are in a single file. Here's my code: // Model struct WatchListModel { let m_id: Int let m_ticker_symbol: String } // View struct WatchlistView: View { @ObservedObject var m_watch_list_view_model: WatchListViewModel init(watch_list_view_model: WatchListViewModel) { m_watch_list_view_model = watch_list_view_model } var body: some View { // This view is causing that issue List(m_watch_list_view_model.m_watch_list_model) { watch_list_model in Text(watch_list_model.m_ticker_symbol) }.onAppear(perform: { self.m_watch_list_view_model.populate_watch_list() }) } } extension
i have an swiftui + coredata app. i want to do the following two things: bulk delete -> a user selects multiple records from list view and when a delete button is clicked, the records selected are deleted bulk update -> a user selects multiple records from list view. and when an edit button is clicked, a new view is pops up where the user can enter what attributes they want to change bulk delete (#1) is working in edit mode by implementing https://stackoverflow.com/questions/57784859/swiftui-how-to-perform-action-when-editmode-changes however, for bulk update (#2), i had a similar code for bulk delete; displaying an update button when in edit mode, but it would not go to other view where i wanted to display list of attributes and update core data and i read the behavior is expected. i have no idea how i can go to other view with the information of which data is selected. i am pretty new to swiftui + coredata. Any idea/suggestion would be app
Hey there! I've been tracking a really weird behavior with a List backed by @FetchRequest from CoreData. When I toggle a bool on the CoreData model, the first time it updates correctly, but if I do it a second time, the UI doesn't re-render as expected. This does not happen if I compile the app using Xcode 16 (targeting both iOS 18 and iOS 26), nor it happens when using Xcode 26 and targeting iOS 18. It only happens when building the app using Xcode 26 and running it on iOS 26. Here are two demos: the first one works as expected, when I toggle the state twice, both times updates. The second one, only on iOS 26, the second toggle fails to re-render. Demo (running from Xcode 16): Demo (running from Xcode 26): The code: import SwiftUI import CoreData @main struct CoreDataTestApp: App { let persistenceController = PersistenceController.shared var body: some Scene { WindowGroup { ContentView() .environment(.managedObjectContext, persistenceController.container.viewContext) } } } struct ContentVie
I've been playing around with the MDLVoxelArray functionality in iOS, to create a mesh algorithmically via voxels. Currently I create the voxel array like this: let minBounds = vector_float3(x: 0.0, y: 0.0, z: 0.0) let maxBounds = vector_float3(x: Float(width), y: Float(height), z: Float(maxDepth)) let boundingBox = MDLAxisAlignedBoundingBox(maxBounds: maxBounds, minBounds: minBounds) let voxels = MDLVoxelArray(data: Data(capacity: MemoryLayout<MDLVoxelIndex>.size * width * height * depth), boundingBox: boundingBox, voxelExtent: 1.0) Then I populate it with indices: var index = MDLVoxelIndex(x: 0, y: 0, z: 0, w: 0) for i in 0 ..< height { ttfor j in 0 ..< width { ttttindex.x = Int32(j) ttttindex.y = Int32(i) ttttlet depth = Int32(heightMap[j][i]) ttttlet midPoint = depth / 2 tttttttt ttttfor k in 0 ... depth { tttttt// w should be 0 at the surface and increase in magnitude towards the middle ttttttlet w = abs(k - midPoint) - midPoint ttttttindex.z = k ttttttindex.w = w ttttttvoxels.setVoxelAtIndex
Sorry. I develop SwiftUI app for watchOS.When a button in a List touched it scale down.Abel9.pngI want to disable a button so it doesn't scale down on touch.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I use relationships and when I delete some items from a list, the data are deleted from the database but they are not removed from the list. I use a simple workaround: After saving the data, I reload the view. import SwiftUI struct CustomView: View { ... var body: some View { ... do { try self.managedObjectContext.save() CustomView() } catch { ... } } }
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I can create a List with an EditButton that supports selecting rows. I can also create a List with an EditButton that supports deleting and moving rows. But I can't seem to create a List that supports selecting, moving, and deleting. Is that possible in SwiftUI?
Only relamquad's answer with UIKit gave me the most confidence and it works. With the flakiness from version to version for SwiftUI's onAppear, just a simple syntax change and everything stops working, relying solely on SwiftUI is too risky. I can't believe this is not high on the bug list. onAppear is such an essential part
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I've been experiencing some serious performance issues with DeviceActivityReport. Their severity tends to vary across devices - for some of my users it's really bad and for some it's mostly fine - but every device seems to experience these issues at some point. 1. DeviceActivityReport is completely blank. Often on launch, the DeviceActivityReport is completely blank and the only way to make it show up is to click back and forth between tabs, or quit the app and re-open it. Sometimes, it will show up after one or two seconds, but that is still a bad user experience. When looking at logs during this issue, I can see that makeConfiguration still runs successfully and returns a value, so I suspect the issue is with the rendering of the View in the App Extension. 2. Gestures are slow to register, or can't register at all. For example, if I place my DeviceActivityReport inside a ScrollView, I cannot scroll if I perform the gesture on the report view. If I try to scroll on the part of the screen th