We have a custom implementation of what we call a “Scrollable Header” in our app. After building with Xcode 26, we’ve observed a change in behavior with the List component. The issue can be seen in the attached GIF: As the user scrolls up, the header is expected to collapse smoothly, and it does—until the moment the next list item becomes visible. At that point, the header collapses prematurely, without any apparent reason. We’ve identified that this behavior occurs after the list’s data-fetching logic runs, which loads additional items as the user scrolls. Below is the ViewModifier responsible for handling the collapsing header logic: @available(iOS 18.0, *) public struct L3CollapseHeaderIOS18: ViewModifier { private let minHeight: Double = 0 private let expandedHeight: CGFloat private let L3Height = 44.0 private let isViewVisible: Bool @Binding private var currentHeight: CGFloat @State private var lastOffset: ScrollOffsetInfo = ScrollOffsetInfo(offset: 0.0, offsetToBottom: 0.0, sc
Search results for
SwiftUI List performance
50,607 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is it possible to find a particular view in SwiftUI based on its tag ?When a row on a List is tapped, I want the textField on a row in another List to be updated.But the problem is I dont know how to get hold of the active textField or the index of the row in the other list.Please refer this image for clarity https://imgur.com/a/Ovv8IBY
This code worked in Xcode 12.0 B1 but no longer works in B2. struct ContentView: View { var body: some View { NavigationView { List { ForEach (1..<10) { row in Text((row) - Test).foregroundColor(Color.white).fontWeight(.bold) } .listRowBackground(Color.burgundy) } .navigationTitle(Text(List Background Color Test)) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .bottomBar) { HStack { Button(action: {}, label: { Text(One).foregroundColor(Color.white) }) Spacer() Button(action: {}, label: { Text(Two).foregroundColor(Color.white) }) Spacer() Button(action: {}, label: { Text(Three).foregroundColor(Color.white) }).foregroundColor(.blue) } } } } } }
You can use an App Intent to perform action that uses your app's functionality but direct communication is not supported. You will need to either Ise App Groups to share a file location Use a SwiftUI button that takes an App Intent as a parameter to call shared code or launch your app and perform a task in response to touch. Rico WWDR | DTS | Software Engineer
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
The following article has a collection of resources for learning Mac development: swiftdevjournal.com/resources-for-learning-mac-development/ Regarding learning SwiftUI or AppKit, you're going to find many more recent articles and tutorials on SwiftUI. Most of these articles are focused on iOS, but most of the material will apply to Mac too. Lists are the one view where you'll run into issues because lists(table views) have much different behavior on Mac than on iOS.
Topic:
UI Frameworks
SubTopic:
AppKit
Tags:
Hy, everyone. I just figured out there are not possibility to perform tripleTap on XCUICoordinate object. There are tap() and doubleTap() methods but not tap(withNumberOfTaps:) like for XCUIElement. Is there any possibility to do this kind of action for XCUICoordinate?
UIKit is not public API on watchOS. :-) What limitations (on List or otherwise) are you finding in SwiftUI that make WatchKit/storyboards a better choice for you?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
It may be possible that macOS is indexing, or performing other background operations after the update. You can check to see if your drive is being indexed by using Spotlight to search anything, and then looking to see if a progress bar appears at the top of the results list. Spotlight indexing can reduce system performance until it's done.
Topic:
App & System Services
SubTopic:
Core OS
Tags:
According to this SO post, you need to add a UUID to each list item: https://stackoverflow.com/questions/61571422/unwanted-animation-when-moving-items-in-swiftui-list. Seems like an odd bug, especially since there is already an ID used in the ForEach.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I can't seem to edit my own post, so I need to clarify that this problem relates to the .colorEffect SwiftUI view modifier. With distortionEffect, where no colorisation is performed, the image renders properly in both Light and Dark mode.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
we’d expect that its body is called when the value changes. Unfortunately, that is a wrong expectation. SwiftUI may call body at any time needed, for example any of the @State variables of the outer view change. Is there any way to avoid this behaviour that can ultimately lead to performance issues? You may need to construct your views as will not lead performance issues, or you can go back to UIKit world.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I have a screen with a list that one side is empty when use on a iPad. as seen in the image or mac is empty . The code below import SwiftUI // How to declare an array var stockalertdtas :[StockAlertDta] = [testStockAlertData,testStockAlertData] struct StockAlertListUIView: View { @StateObject var viewModel = StockAlertListUIViewModel() @Environment(.horizontalSizeClass) var horizontalSizeClass @State var firstSelection: StockAlertDta? var body: some View { NavigationView{ ZStack{ //how to select the first value in the f List() { ForEach(viewModel.userStockAlertDtas, id:.self){ stockalert in NavigationLink(destination: StockDetailUIView(stockAlert: stockalert), tag: stockalert, selection: self.$firstSelection) { StockAlertRow(stockAlertDta: stockalert) } }.onDelete(perform: { IndexSet in IndexSet.forEach{ array_id in viewModel.deleteItem(atOffsets: array_id) } viewModel.userStockAlertDtas.remove(atOffsets: IndexSet) }) } if viewModel.userStockAlertDtas.isEmpty { EmptyState(i
my 2 cents for SwiftUI in a cross platform way (Hope help others) import SwiftUI #if os(iOS) import UIKit #elseif os(macOS) import AppKit #endif struct ContentView: View { var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) Text(Hello, world!) } .onAppEnteredBackground { print(going back) } } } //MARK: extension #if os(iOS) fileprivate let GO_DOWN = UIApplication.didEnterBackgroundNotification #elseif os(macOS) fileprivate let GO_DOWN = NSApplication.didResignActiveNotification #endif extension View { func onNotification( _ notificationName: Notification.Name, perform action: @escaping () -> Void ) -> some View { onReceive(NotificationCenter.default.publisher( for: notificationName )) { _ in action() } } func onAppEnteredBackground( perform action: @escaping () -> Void ) -> some View { onNotification( GO_DOWN, perform: action ) } }
Topic:
UI Frameworks
SubTopic:
UIKit
Tags:
Thanks for flagging this, this looks like a bug to me. Adding let _ = Self._printChanges() in the view body provides a better explanation as to what's going on here. In essence dismiss is causing a re-render of the SwiftUI view because of an updated value. It doesn't cause duplicate navigation events but it still could be a performance issue. See Demystify SwiftUI performance to learn more about common causes behind performance issues Please open a bug report, include your findings and the test environment. Please post the FB number here once you do.Bug Reporting: How and Why? has tips on creating your bug report. An alternative approach you could consider is to programmatically manage your navigation using a path input. Please review the following resources to learn about programmatic navigation: Update programmatic navigation Manage navigation state
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
(Continued) Are there any actual game sample projects available to download? See Metal Sample Code Library Try Bring your advanced games to Mac, iPad, and iPhone. This tutorial covers essential technologies for implementing games on Apple platforms, including Metal rendering, audio, input, and display APIs. See Port advanced games to Apple platforms See Design advanced games for Apple platforms Inspired by Liquid Glass, I want to add shader effects to my app in SwiftUI, but I'm concerned about performance. How do Metal shaders fit in to the SwiftUI layout/drawing system, and are there any performance pitfalls to watch out for? SwiftUI invokes your shaders during rendering. We recommend Optimize SwiftUI performance with Instruments to understand the performance impact of Metal shaders executed during a SwiftUI rendering pass. A newbie to Apple Developer Experience - where can I start if i want to start learning to create games (i
Topic:
Graphics & Games
SubTopic:
Metal
Tags: