Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

Dynamically Update Complex UI Views in SwiftUI
I am working on a SwiftUI project where I need to dynamically update the UI by adding or removing components based on some event. The challenge is handling complex UI structures efficiently while ensuring smooth animations and state management. Example Scenario: I have a screen displaying a list of items. When a user taps an item, additional details (like a subview or expanded section) should appear dynamically. If the user taps again, the additional content should disappear. The UI should animate these changes smoothly without causing unnecessary re-renders. My Current Approach: I have tried using @State and if conditions to toggle views, like this: struct ContentView: View { @State private var showDetails = false var body: some View { VStack { Button("Toggle Details") { showDetails.toggle() } if showDetails { Text("Additional Information") .transition(.slide) // Using animation } } .animation(.easeInOut, value: showDetails) } } However, in complex UI scenarios where multiple components need to be shown/hidden dynamically, this approach is not maintainable and could cause performance issues. I need help with the below questions. Questions: State Management: Should I use @State, @Binding, or @ObservedObject for handling dynamic UI updates efficiently? Best Practices: What are the best practices for structuring SwiftUI views to handle dynamic updates without excessive re-renders? Performance Optimization: How can I prevent unnecessary recomputations when updating only specific UI sections? Animations & Transitions: What is the best way to apply animations smoothly while toggling visibility of multiple components? Advanced Approaches: Are there better techniques using @EnvironmentObject, ViewBuilder, or even GeometryReader for dynamically adjusting UI layouts? Any insights, code examples, or resources would be greatly appreciated.
0
0
348
Jan ’25
iOS18 UIPinchGestureRecognizer finger change
Before ios18, when two fingers are switched to single fingers, the printing scale value will not change. When switching to two fingers again, the pinch and zoom printing scale will change. The same operation is performed after ios18, and two fingers are switched to single fingers. Switch back to two fingers, and the scale printing will not change. code here: - (void)pinchGesture:(UIPinchGestureRecognizer *)recognizer { NSSet <UIEvent*> *events = [recognizer valueForKey:@"_activeEvents"]; UIEvent *event = [events anyObject]; if (recognizer.state == UIGestureRecognizerStateBegan) { NSLog(@"---- begin finger count: %d scale: %f",event.allTouches.count,recognizer.scale); recognizer.scale = 1.0; } else if (recognizer.state == UIGestureRecognizerStateChanged) { NSLog(@"---- change finger count: %d scale: %f",event.allTouches.count,recognizer.scale); // recognizer.scale = 1.0; } log image for iOS 17.7 log image for ios18.0.2
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
297
Jan ’25
macOS: First Hangul input ignored/separated after locale change or initial focus with default Korean IME
I reported Korean IME bug to QT Bug report. Please refer to below link. https://bugreports.qt.io/browse/QTBUG-136128?jql=text%20~%20korean%20ORDER%20BY%20created%20DESC But, QT reponsed me like follwing. Thank you for reporting. However, this issue seems like a known issue with apple's Korean IME. There are many threads in Korean community about the same problem with Non-Qt apps. If this issue is a really Qt issue, feel free to open it again. Is there any workaround to fix this IME bug ? Thanks, Ted
0
0
116
May ’25
[SwiftUI] Gesture Conflict: simultaneousGesture Causes Incorrect Gesture Recognition in iOS 18
Subject: SwiftUI Gesture Conflict in iOS 18: Simultaneous Recognition of Drag and Tap Gestures Description: In SwiftUI on iOS 18 and above, we've identified an issue with gesture handling that affects user experience. When implementing .simultaneousGesture(DragGesture()), the system incorrectly recognizes and processes both drag and tap gestures concurrently, resulting in unintended behavior. Technical Details: Environment: SwiftUI, iOS 18+ Issue: Simultaneous recognition of horizontal drag gestures and vertical scroll/tap gestures Current Behavior: Both vertical and horizontal scrolling occur simultaneously when using .simultaneousGesture(DragGesture()) Expected Behavior: Gestures should be properly disambiguated to prevent concurrent scrolling in multiple directions Impact: This behavior significantly impacts user experience, particularly in custom carousel implementations and other UI components that rely on precise gesture handling. The simultaneous recognition of both gestures creates a confusing and unpredictable interaction pattern. Steps to Reproduce: Create a SwiftUI view with horizontal scrolling (e.g., custom carousel) Implement .simultaneousGesture(DragGesture()) Add tap gesture recognition to child views Run on iOS 18 Attempt to scroll horizontally Observed Result: Both horizontal dragging and vertical scrolling/tapping are recognized and processed simultaneously, creating an inconsistent user experience. Expected Result: The system should properly disambiguate between horizontal drag gestures and vertical scroll/tap gestures, allowing only one type of gesture to be recognized at a time based on the user's intent. Please let me know if you need any additional information or reproduction steps.
0
0
107
Apr ’25
LaunchScreen is black when i use image set
Anybody can help me with the problems of splashboard? My request is to create a launchScreen.storyboard that can follows system's theme. So in the storyboard i use the image set resource which is created in Assets.xcassets. But i encountered the following problems: when i use image set resource,the splashboard is black, seems like springboard fail to generate the ktx file. But when i move the same image file to the root of Resource directory, it works. Why???? Some image works when it is put in Image set, some file can't. But all file don't work when the image set contains both light image and dark image. Why??? Suddenly it works for when i change compression attribute to lossess,so i guess the problems hanppened when my image is compressed. And two days later, the splash board is dark again when i debug. So what is the cache strategy for the splash board and the image resource used. How can i clear the cache, delete the app is not enough? Should i restart my phone? That's all, anybody can help me?
Topic: UI Frameworks SubTopic: General
0
0
40
Apr ’25
How to customize item transitions inside a Picker View?
I have a simple Picker where the options available change by the view state. I would like to have the transition animated but the default animation is not good so I tried setting a .transition() and or an .animation() inside an item on the picker but it is ignored. The same happens if the transition is set on the picker itself since it's always present. Am I doing it right and is just not posible or is there something else to do? Code to reproduce the issue: struct ContentView: View { @State var list: [String] = [ "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", ] @State var selected: String? @State var toggle: Bool = false var body: some View { VStack { Picker("List", selection: $selected) { ForEach(list, id: \.self) { Text($0).tag($0) // .transition(.opacity) } } .pickerStyle(.segmented) // .transition(.opacity) HStack { Button(action: swapOptions) { Text("Swap") } } } .padding() } } extension ContentView { func swapOptions() { withAnimation { toggle.toggle() switch toggle { case true: list = [ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", ] case false: list = [ "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", ] } } } } ``
Topic: UI Frameworks SubTopic: SwiftUI
0
0
76
May ’25
*** -colorSpaceName not valid
Here is a relatively simple code fragment: let attributedQuote: [NSAttributedString.Key: Any] = [ .font: FieldFont!, .foregroundColor: NSColor.red] let strQuote = NSAttributedString.init(string:"Hello World", attributes:attributedQuote) strQuote.draw(in: Rect1) It compiles without an issue, bur when I execute it, I get: "*** -colorSpaceName not valid for the NSColor <NSColor: 0x6000005adfd0>; need to first convert colorspace." I have tried everything I can think of. What's going on?
0
1
396
Jan ’25
Live Activity animate without updating data
Is it actually possible to display animation (even a simple one) on Live Activity? But on these cases: The main app is terminated - of course, I know I can use the main app to keep updating the Live Activity to make simple animations work, but in this case, the main app is killed. Live Activity data is not updating - I also understand that the Live Activity can perform animations when its data is being update via push notification or other means, but the current case is the data is not being updated. I’ve tried several ways to achieve this, but nothing seems to work. Just when I was about to give up, I found this video from Apple’s official channel: https://www.youtube.com/watch?v=m6WMwSj_EbA At 4:14 in this video, you can see the text "Locating Driver" with the breathing animation. Could someone please help me understand how to implement that kind of animation in a Live Activity when: The main app is not running, and The Live Activity data is not updating?
0
0
137
Apr ’25
Xcode UIKit Document App template crashes under Swift 6
I'm trying to switch to UIKit's document lifecycle due to serious bugs with SwiftUI's version. However I'm noticing the template project from Xcode isn't compatible with Swift 6 (I already migrated my app to Swift 6.). To reproduce: File -> New -> Project Select "Document App" under iOS Set "Interface: UIKit" In Build Settings, change Swift Language Version to Swift 6 Run app Tap "Create Document" Observe: crash in _dispatch_assert_queue_fail Does anyone know of a work around other than downgrading to Swift 5?
0
1
91
Apr ’25
Siri Shortcuts of Siri Intent to Voice Control Parts of App
I am new to the idea of Siri Shortcuts and App Intents. What I want to do is use Siri to run a function in my app. Such as saying to Siri Zoom in map and that will then call a function in my app where I can zoom in the map. Similarly, I could say Zoom out map and it would call a function to zoom out my map. I do not need to share any sort of shortcut with the Shortcuts app. Can someone please point me in the right direction for what type of intents I need to use for this?
0
0
85
Apr ’25
VideoToolbox crash in macOS
My Mac app crashes for some users inside VideoToolbox, and I'm not sure what to do with that, and how to fix it. Here are couple of examples that repeating again and again for macOS 15.* Thread 10 Crashed: 0 libsystem_pthread.dylib 0x000000018535a8e0 0x185359000 + 6368 1 VideoToolbox 0x0000000194f3e218 0x194f28000 + 90648 2 VideoToolbox 0x00000001951de384 0x194f28000 + 2843524 3 libxpc.dylib 0x000000018506f2c0 0x185060000 + 62144 4 libxpc.dylib 0x000000018506da14 0x185060000 + 55828 5 libdispatch.dylib 0x00000001851ad674 0x1851a9000 + 18036 6 libdispatch.dylib 0x00000001851c9c88 0x1851a9000 + 134280 7 libdispatch.dylib 0x00000001851b4a38 0x1851a9000 + 47672 8 libdispatch.dylib 0x00000001851ca9dc 0x1851a9000 + 137692 9 libdispatch.dylib 0x00000001851b4a38 0x1851a9000 + 47672 10 libdispatch.dylib 0x00000001851b5764 0x1851a9000 + 51044 11 libdispatch.dylib 0x00000001851bf4cc 0x1851a9000 + 91340 12 libdispatch.dylib 0x00000001851bf260 0x1851a9000 + 90720 13 libsystem_pthread.dylib 0x00000001853602e4 0x185359000 + 29412 14 libsystem_pthread.dylib 0x000000018535b0fc 0x185359000 + 8444 and Thread 10 Crashed: 0 libsystem_pthread.dylib 0x00000001981fc364 0x1981fb000 + 4964 1 VideoToolbox 0x00000001a85f9964 0x1a81e8000 + 4266340 2 VideoToolbox 0x00000001a847a840 0x1a81e8000 + 2697280 3 libxpc.dylib 0x0000000197f09830 0x197efb000 + 59440 4 libxpc.dylib 0x0000000197f0812c 0x197efb000 + 53548 5 libdispatch.dylib 0x00000001980638a4 0x198048000 + 112804 6 libdispatch.dylib 0x00000001980660e8 0x198048000 + 123112 7 libdispatch.dylib 0x00000001980521b8 0x198048000 + 41400 8 libdispatch.dylib 0x0000000198066e4c 0x198048000 + 126540 9 libdispatch.dylib 0x00000001980521b8 0x198048000 + 41400 10 libdispatch.dylib 0x0000000198052e60 0x198048000 + 44640 11 libdispatch.dylib 0x000000019805be30 0x198048000 + 81456 12 libdispatch.dylib 0x000000019805bbf0 0x198048000 + 80880 13 libsystem_pthread.dylib 0x0000000198201c0c 0x1981fb000 + 27660 14 libsystem_pthread.dylib 0x00000001981fcb80 0x1981fb000 + 7040 and this one is for macOS 14 Thread 10 Crashed: 0 VideoToolbox 0x000000018f12ac90 0x18f11d000 + 56464 1 VideoToolbox 0x000000018f130a80 0x18f11d000 + 80512 2 VideoToolbox 0x000000018f131090 0x18f11d000 + 82064 3 VideoToolbox 0x000000018f130f94 0x18f11d000 + 81812 4 Remote for Mac 0x00000001048d521c 0x1048d0000 + 21020 5 Foundation 0x000000018174796c 0x181709000 + 256364 6 Foundation 0x000000018174782c 0x181709000 + 256044 7 Foundation 0x00000001817477bc 0x181709000 + 255932 8 Foundation 0x0000000181746b64 0x181709000 + 252772 9 Foundation 0x00000001817468d4 0x181709000 + 252116 10 Foundation 0x00000001817467c4 0x181709000 + 251844 11 libdispatch.dylib 0x00000001803b0470 0x18039d000 + 78960 12 libdispatch.dylib 0x00000001803a13e8 0x18039d000 + 17384 13 libdispatch.dylib 0x00000001803a48ec 0x18039d000 + 30956 14 libdispatch.dylib 0x00000001803a3f08 0x18039d000 + 28424 15 libdispatch.dylib 0x00000001803b2ea8 0x18039d000 + 89768 16 libdispatch.dylib 0x00000001803b36b8 0x18039d000 + 91832 17 libsystem_pthread.dylib 0x000000018054dfd0 0x18054b000 + 12240 18 libsystem_pthread.dylib 0x000000018054cd28 0x18054b000 + 7464
0
0
71
Apr ’25
searchable isPresented set too late in a sheet
I have a popover/sheet in iOS which allows users to search and add items to a list. When the sheet is shown, the search should always be active. I am using searchable on a NavigationStack inside the sheet. I am using the isPresented parameter to activate search. My issue is with the animation of the search activation. Even if I use... isPresented: .constant(true) ...the search isn't activated until the sheet has completed it's entrance animation, resulting in two stages of animation. I can't add a video here, but the two images below show the steps I am seeing. First a slide up animation, with the search in the navigation drawer, then a second animation, once the sheet is fully in place, as the search becomes active. Is it possible to merge these two animations, so search is in place when the sheet animates up?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
45
Apr ’25
NSDocument duplicate problem
The aim is to save the data of a program in 2 different formats of choice, say type1 (default) and type2. No problem when + (BOOL)autosavesInPlace is NO, you can save as… and get a choice. No problem when + (BOOL)autosavesInPlace is YES and you created a new document, you can choose when saving. But you do not get a choice when you created the new file by duplicating a existing file. It takes the type of the latter. (Using dataOfType:error:, but did not find a solution either by using writeToURL:ofType:error:, duplicateDocument:, etc.)
Topic: UI Frameworks SubTopic: AppKit
0
0
303
Jan ’25
cannot save event
iOS 18.4.1 When I change a Google type event to an iCloud type, a "Cannot Save Event" prompt box pops up. We have also received user feedback that recurring events also fail to save. After updating to iOS 18.4 when trying to save changes to an existing repeating event, the message "Cannot Save Event" will appear. EventKitUI
Topic: UI Frameworks SubTopic: UIKit
0
0
63
May ’25
Explanation of DynamicProperty's update func in SwiftUI
Could an Apple employee that works on SwiftUI please explain the update() func in the DynamicProperty protocol? The docs have ambiguous information, e.g. "Updates the underlying value of the stored value." and "SwiftUI calls this function before rendering a view’s body to ensure the view has the most recent value." From: https://developer.apple.com/documentation/swiftui/dynamicproperty/update() How can it both set the underlying value and get the most recent value? What does underlying value mean? What does stored value mean? E.g. Is the code below correct? struct MyProperty: DynamicProperty { var x = 0 mutating func update() { // get x from external storage x = storage.loadX() } } Or should it be: struct MyProperty: DynamicProperty { let x: Int init(x: Int) { self.x = x } func update() { // set x on external storage storage.save(x: x) } } This has always been a mystery to me because of the ambigious docs so thought it was time to post a question.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
220
Jan ’25
Custom slider png on gui
Im student, hobbyst on developing. i have a problem inserting a custom slidee PNG to control volume of an áudio file in an app. The slidee built in Swift, runs ok. When i try to use a custom png it show in the Gui but when move its button right it disappear beyond the maximum but when i move ir left the minimamente is at middle of the slider scale
Topic: UI Frameworks SubTopic: SwiftUI
0
0
41
Apr ’25
Food Truck Sample animation issue from Table Component
Hi! I'm seeing some weird animation issues building the Food Truck sample application.^1 I'm running from macOS 15.4 and Xcode 16.3. I'm building the Food Truck application for macOS. I'm not focusing on iOS for now. The FoodTruckModel adds new Order values with an animation: // FoodTruckModel.swift withAnimation(.spring(response: 0.4, dampingFraction: 1)) { self.orders.append(orderGenerator.generateOrder(number: orders.count + 1, date: .now, generator: &generator)) } This then animates the OrdersTable when new Order values are added. Here is a small change to OrdersTable: // OrdersTable.swift - @State private var sortOrder = [KeyPathComparator(\Order.status, order: .reverse)] + @State private var sortOrder = [KeyPathComparator(\Order.creationDate, order: .reverse)] Running the app now inserts new Order values at the top. The problem is I seem to be seeing some weird animation issues here. It seems that as soon as the new Order comes in there is some kind of weird glitch where it appears as if part the animation is coming from the side instead of down from the top: What's then more weird is that if I seem to affect the state of the Table in any way then the next Order comes in with perfect animation. Scrolling the Table fixes the animation. Changing the creationData sort order from reverse to forward and back to reverse fixes the animation. Any ideas? Is there something about how the Food Truck product is built that would cause this to happen? Is this an underlying issue in the SwiftUI infra?
0
0
60
Apr ’25
UIInputView not being deallocated
I am experiencing memory leaks in my iOS app that seem to be related to an issue between UIInputView and _UIInputViewContent. After using the memory graph, I'm seeing that instances of these objects aren't being deallocated properly. The UIInputViewController whichs holds the inputView is being deallocated properly along with its subviews.I have tried to remove all of UIInputViewController's subviews and their functions but the uiInputView is not being deallocated. The current setup of my app is a collectionView with multiple cell,each possessing a textfield with holds a UIInputViewController.When i scroll up or down,the views are being reused as expected and the number of UIInputViewController stays consistent with the number of textfields.However the number of inputView keeps increasing referencing solely _UIInputViewContent. class KeyboardViewController: UIInputViewController { // Callbacks var key1: ((String) -> Void)? var key2: (() -> Void)? var key3: (() -> Void)? var key4: (() -> Void)? private lazy var buttonTitles = [ ["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"] ] override func viewDidLoad() { super.viewDidLoad() setupKeyboard() } lazy var mainStackView: UIStackView = { let mainStackView = UIStackView() mainStackView.axis = .vertical mainStackView.distribution = .fillEqually mainStackView.spacing = 16 mainStackView.translatesAutoresizingMaskIntoConstraints = false return mainStackView }() private func setupKeyboard() { let keyboardView = UIView(frame:CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 279.0)) keyboardView.addSubview(mainStackView) NSLayoutConstraint.activate([ mainStackView.topAnchor.constraint(equalTo: keyboardView.topAnchor, constant: 16), mainStackView.leadingAnchor.constraint(equalTo: keyboardView.leadingAnchor, constant: 0), mainStackView.trailingAnchor.constraint(equalTo: keyboardView.trailingAnchor, constant: -24), mainStackView.bottomAnchor.constraint(equalTo: keyboardView.bottomAnchor, constant: -35) ]) // Create rows for (_, _) in buttonTitles.enumerated() { let rowStackView = UIStackView() rowStackView.axis = .horizontal rowStackView.distribution = .fillEqually rowStackView.spacing = 1 // Create buttons for each row for title in rowTitles { let button = createButton(title: title) rowStackView.addArrangedSubview(button) } mainStackView.addArrangedSubview(rowStackView) } self.view = keyboardView } private func createButton(title: String) -> UIButton { switch title { ///returns a uibutton based on title } } // MARK: - Button Actions @objc private func numberTapped(_ sender: UIButton) { if let number = sender.title(for: .normal) { key1?(number) } } @objc private func key2Called() { key2?() } @objc private func key3Called() { key3?() } @objc private func key4Called() { key4?() } deinit { // Clear any strong references key1 = nil key2 = nil key3 = nil key4 = nil for subview in mainStackView.arrangedSubviews { if let stackView = subview as? UIStackView { for button in stackView.arrangedSubviews { (button as? UIButton)?.removeTarget(self, action: nil, for: .allEvents) } } } mainStackView.removeFromSuperview() } } Environment iOS 16.3 Xcode 18.3.1 Any insights would be greatly appreciated as this is causing noticeable memory growth in my app over time.
0
0
71
Apr ’25