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

Implement Continuity Markup in Mac app?
Hello, is there a way to implement Continuity Markup in our own apps? (This is what I'm talking about: https://support.apple.com/en-us/102269 , scroll down to "Use Continuity Markup"). Also, why does a QuickLook panel (QLPreviewPanel.shared()) not display the markup options when triggered from my app for png image files in my app's Group Container? Do I need to implement certain NSServicesMenuRequestor methods for that? Sadly, I could not find any docs on that. Thank you, – Matthias
0
0
109
Apr ’25
Get NSTextView selection frame with NSTextLayoutManager
I'm trying to update my app to use TextKit 2. The one thing that I'm still not sure about is how I can get the selection frame. My app uses it to auto-scroll the text to keep the cursor at the same height when the text wraps onto a new line or a newline is manually inserted. Currently I'm using NSLayoutManager.layoutManager!.boundingRect(forGlyphRange:in:). The code below almost works. When editing the text or changing the selection, the current selection frame is printed out. My expectation is that the selection frame after a text or selection change should be equal to the selection frame before the next text change. I've noticed that this is not always true when the text has a NSParagraphStyle with spacing > 0. As long as I type at the end of the text, everything's fine, but if I insert some lines, then move the selection somewhere into the middle of the text and insert another newline, the frame printed after manually moving the selection is different than the frame before the newline is inserted. It seems that the offset between the two frames is exactly the same as the paragraph style's spacing. Instead when moving the selection with the arrow key the printed frames are correct. I've filed FB17104954. class ViewController: NSViewController, NSTextViewDelegate { private var textView: NSTextView! override func loadView() { let scrollView = NSScrollView(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) textView = NSTextView(frame: scrollView.frame) textView.autoresizingMask = [.width, .height] textView.delegate = self let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 40 textView.typingAttributes = [.foregroundColor: NSColor.labelColor, .paragraphStyle: paragraphStyle] scrollView.documentView = textView scrollView.hasVerticalScroller = true view = scrollView } func textView(_ textView: NSTextView, shouldChangeTextIn affectedCharRange: NSRange, replacementString: String?) -> Bool { print("before", selectionFrame.maxY, selectionFrame) return true } func textDidChange(_ notification: Notification) { print("after ", selectionFrame.maxY, selectionFrame) } func textViewDidChangeSelection(_ notification: Notification) { print("select", selectionFrame.maxY, selectionFrame) } var selectionFrame: CGRect { guard let selection = textView.textLayoutManager!.textSelections.first?.textRanges.first else { return .null } var frame = CGRect.null textView.textLayoutManager!.ensureLayout(for: selection) textView.textLayoutManager!.enumerateTextSegments(in: selection, type: .selection, options: [.rangeNotRequired]) { _, rect, _, _ in frame = rect return false } return frame } }
0
1
101
Apr ’25
Is MapKit.mapCameraKeyframeAnimator broken on macOS 15.2?
Hi! I'm attempting to run the Quakes Sample App^1 from macOS. I am running breakpoints and confirming the mapCameraKeyframeAnimator is being called: .mapCameraKeyframeAnimator(trigger: selectedId) { initialCamera in let start = initialCamera.centerCoordinate let end = quakes[selectedId]?.location.coordinate ?? start let travelDistance = start.distance(to: end) let duration = max(min(travelDistance / 30, 5), 1) let finalAltitude = travelDistance > 20 ? 3_000_000 : min(initialCamera.distance, 3_000_000) let middleAltitude = finalAltitude * max(min(travelDistance / 5, 1.5), 1) KeyframeTrack(\MapCamera.centerCoordinate) { CubicKeyframe(end, duration: duration) } KeyframeTrack(\MapCamera.distance) { CubicKeyframe(middleAltitude, duration: duration / 2) CubicKeyframe(finalAltitude, duration: duration / 2) } } But I don't actually see any map animations taking place when that selection changes. Running the application from iPhone simulator does show the animations. I am building from Xcode Version 16.2 and macOS 15.2. Are there known issues with this API on macOS?
0
0
292
Dec ’24
Title: Frequent SIGSEGV crashes in QuartzCore's copy_image (iOS 18.4) We're experiencing numerous crashes with the following signature:
Title: Frequent SIGSEGV crashes in QuartzCore's copy_image (iOS 18.4) We're experiencing numerous crashes with the following signature: Exception Codes: fault addr: 0x00000000000000e0 Crashed Thread: 0 Thread 0 0 QuartzCore CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, double) + 1972 1 QuartzCore CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, double) + 1260 2 QuartzCore CA::Render::prepare_image(CGImage*, CGColorSpace*, unsigned int, double) + 24 3 QuartzCore CA::Layer::prepare_contents(CALayer*, CA::Transaction*) + 220 4 QuartzCore CA::Layer::prepare_commit(CA::Transaction*) + 284 5 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 488 6 QuartzCore CA::Transaction::commit() + 644 7 UIKitCore ___34-[UIApplication _firstCommitBlock]_block_invoke_2 + 36 8 CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 9 CoreFoundation ___CFRunLoopDoBlocks + 352 10 CoreFoundation ___CFRunLoopRun + 868 11 CoreFoundation _CFRunLoopRunSpecific + 572 12 GraphicsServices _GSEventRunModal + 168 13 UIKitCore -[UIApplication _run] + 816 14 UIKitCore _UIApplicationMain + 336 15 kugou _main + 132 16 dyld __dyld_process_info_create + 33284 Observations: 1.Crashes consistently occur in Core Animation's image processing pipeline 2.100% of occurrences are on iOS 18.4 devices 3.Crash signature suggests memory access violation during image/copy operations 4.Not tied to any specific device model Questions for Apple: 1.Is this crash pattern recognized as a known issue in iOS 18.4? 2.Are there specific conditions that could trigger SEGV_ACCERR in CA::Render::copy_image? 3.Could this be related to color space handling or image format requirements changes? 4.Any recommended workarounds while waiting for a system update?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
1
119
Apr ’25
Data Fetch issue from SensorKit
I want use SensorKit data for research purposes in my current app. I have applied for and received permission from Apple to access SensorKit Data. I have granting all the necessary permissions. But no data retrieved. I am using didCompleteFetch for retrieving data from Sensorkit. CompleteFetch method calls but find the data. Below is my SensorKitManager Code. import SensorKit import Foundation protocol SensorManagerDelegate: AnyObject { func didFetchPhoneUsageReport(_ reports: [SRPhoneUsageReport]) func didFetchAmbientLightSensorData(_ data: [SRAmbientLightSample]) func didFailFetchingData(error: Error) } class SensorManager: NSObject, SRSensorReaderDelegate { private let phoneUsageReader: SRSensorReader private let ambientLightReader: SRSensorReader weak var delegate: SensorManagerDelegate? override init() { self.phoneUsageReader = SRSensorReader(sensor: .phoneUsageReport) self.ambientLightReader = SRSensorReader(sensor: .ambientLightSensor) super.init() self.phoneUsageReader.delegate = self self.ambientLightReader.delegate = self } func requestAuthorization() { let sensors: Set<SRSensor> = [.phoneUsageReport, .ambientLightSensor] guard phoneUsageReader.authorizationStatus != .authorized || ambientLightReader.authorizationStatus != .authorized else { log("Already authorized. Fetching data directly...") fetchSensorData() return } SRSensorReader.requestAuthorization(sensors: sensors) { [weak self] error in DispatchQueue.main.async { if let error = error { self?.log("Authorization failed: \(error.localizedDescription)", isError: true) self?.delegate?.didFailFetchingData(error: error) } else { self?.log("Authorization granted.") self?.fetchSensorData() } } } } func fetchSensorData() { guard let fromDate = Calendar.current.date(byAdding: .day, value: -1, to: Date()) else { log("Failed to calculate 'from' date.", isError: true) return } let fromTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: fromDate.timeIntervalSinceReferenceDate) let toTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: Date().timeIntervalSinceReferenceDate) let phoneUsageRequest = SRFetchRequest() phoneUsageRequest.from = fromTime phoneUsageRequest.to = toTime phoneUsageRequest.device = SRDevice.current let ambientLightRequest = SRFetchRequest() ambientLightRequest.from = fromTime ambientLightRequest.to = toTime ambientLightRequest.device = SRDevice.current phoneUsageReader.fetch(phoneUsageRequest) ambientLightReader.fetch(ambientLightRequest) } // ✅ Delegate Methods func sensorReader(_ reader: SRSensorReader, didCompleteFetch fetchRequest: SRFetchRequest) { Task.detached { if reader.sensor == .phoneUsageReport { if let samples = reader.fetch(fetchRequest) as? [SRPhoneUsageReport] { DispatchQueue.main.async { [weak self] in self?.delegate?.didFetchPhoneUsageReport(samples) } } } else if reader.sensor == .ambientLightSensor { if let samples = reader.fetch(fetchRequest) as? [SRAmbientLightSample] { DispatchQueue.main.async { [weak self] in self?.delegate?.didFetchAmbientLightSensorData(samples) } } } } } func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject>) -> Bool { return true } func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, failedWithError error: any Error) { DispatchQueue.main.async { [weak self] in self?.delegate?.didFailFetchingData(error: error) } } // MARK: - Logging Helper private func log(_ message: String, isError: Bool = false) { if isError { print("❌ [SensorManager] \(message)") } else { print("✅ [SensorManager] \(message)") } } } And ViewController import UIKit import SensorKit class ViewController: UIViewController { private var sensorManager: SensorManager! override func viewDidLoad() { super.viewDidLoad() setupSensorManager() } private func setupSensorManager() { sensorManager = SensorManager() sensorManager.delegate = self sensorManager.requestAuthorization() } } // MARK: - SensorManagerDelegate extension ViewController: SensorManagerDelegate { func didFetchPhoneUsageReport(_ reports: [SRPhoneUsageReport]) { for report in reports { print("Total Calls: (report.totalOutgoingCalls + report.totalIncomingCalls)") print("Outgoing Calls: (report.totalOutgoingCalls)") print("Incoming Calls: (report.totalIncomingCalls)") print("Total Call Duration: (report.totalPhoneCallDuration) seconds") } } func didFetchAmbientLightSensorData(_ data: [SRAmbientLightSample]) { for sample in data { print(sample) } } func didFailFetchingData(error: Error) { print("Failed to fetch data: \(error.localizedDescription)") } } Could anyone please assist me in resolving this issue? Any guidance or troubleshooting steps would be greatly appreciated.
0
0
124
Mar ’25
SwiftUI Text is larger when empty
I have a simple SwiftUI Text: Text(t) .font(Font.system(size: 9)) Strangely its ideal height seems to be larger when it is empty. I initially observed this in a custom Layout container that wasn't working quite right. Eventually I looked at the height returned by v.dimensions(in:), and found that when t is non-empty the height is 11; when empty, it's 14. Subsequently I observed similar behaviour in a regular VStack container. Has anyone seen anything similar? Are there any properties that could affect this behaviour? (This is on a watch - I don't know if that matters.)
0
0
306
Jan ’25
Form - Multiplatform - Alignment off - HStack ?
Not sure what could cause this. the UI align differently running on iPhone versus running on Mac. If I remove the HStack, it works but I still would like to know why, and if there is a way to make it right on both platforms. Thank you here is my code @State private var viewModel = FirmwareSelectionViewModel() var body: some View { Form { Section("Setup Name") { TextField ( "", text: $viewModel.setupName ) .foregroundColor(.green ) .disableAutocorrection(true) .onSubmit { print ("On Submit") } } Section("Battery") { HStack() { Text("Volt") TextField("", value: $viewModel.Vnominal, format: .number) .textFieldStyle(.roundedBorder) .foregroundColor(.green ) #if !os(macOS) .keyboardType(.decimalPad) #endif .onChange(of: viewModel.Vnominal) { viewModel.checkEntryValidity() print("Updated Vnominal: \(viewModel.Vnominal)") } Text("Ah") TextField("", value: $viewModel.batteryCapacity, format: .number) .textFieldStyle(.roundedBorder) .foregroundColor(.green ) #if !os(macOS) .keyboardType(.decimalPad) #endif .onChange(of: viewModel.batteryCapacity) { viewModel.checkEntryValidity() print("Updated Battery Capacity: \(viewModel.batteryCapacity)") } } } Section("Firmware Type") { Picker(selection: $viewModel.selectedType, label: EmptyView()) { ForEach(TypeOfFirmware.allCases) { type in Text(type.rawValue).tag(type as TypeOfFirmware) .foregroundColor(.green ) } } .pickerStyle(SegmentedPickerStyle()) Picker(selection: $viewModel.selectedFirmware, label: EmptyView()) { ForEach(viewModel.availableFirmware) { firmware in Text(firmware.rawValue.capitalized).tag(firmware as Firmware) } } .pickerStyle(SegmentedPickerStyle()) } } .onChange(of: viewModel.selectedType) { viewModel.resetFirmwareSelection() } .navigationTitle("Firmware Selection") } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
175
Jan ’25
Can We Detect When Running Behind a Slide Over Window?
I'm trying to determine if it’s possible to detect when a user interacts with a Slide Over window while my app is running in the background on iPadOS. I've explored lifecycle methods such as scenePhase and various UIApplication notifications (e.g., willResignActiveNotification) to detect focus loss, but these approaches don't seem to capture the event reliably. Has anyone found an alternative solution or workaround for detecting this specific state change? Any insights or recommended practices would be greatly appreciated.
0
0
88
Mar ’25
Adding Markdown support in notes app
Hi guys, I’m making a simple note taking app and I want to support markdown functionality. I have tried to find libraries and many other GitHub repos but some of them are slow and some of them are very hard to implement and not very customizable. In WWDC 22 apple also made a markdown to html document app and I also looked at that code and it was awesome. It was fast and reliable (Apple btw). But the only problem I am facing is that the markdown text is on the left side and the output format is on the right in the form of html. I don’t want that I want both in the same line. In bear notes and things 3 you can write in markdown and you can see that it is converting in the same line. I have also attached example videos. So, I have markdown parser by apple but the only thing in the way is that it is converting it into a html document. Please help me with this. Also please look into the things 3 video they have also completely customized the text attributes selection menu. By default with UITextView we can only enable text attributes and it shows like this. By clicking more we get the complete formatting menu but not the slider menu which is more convenient. Please also help me this. I don’t know if I can provide apple file but it is from wwdc 22 supporting desktop class interaction
0
0
363
Feb ’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
65
Apr ’25
How to make app for iPhone and iPad separatly
I released an app for iPhone (and it's could be downloaded for iPad also), and now I developered another app for iPad version with the same code and logic but I modified the layout to fit bigger screen and make better user experience and appearance. Howevert the app review rejected my release due to the duplicate content, how can I solve it?
Topic: UI Frameworks SubTopic: General
0
0
41
Mar ’25
QuickLook Library updated text tampered on PDF
We were using below delegate methods from QuickLook to get modified PDF file URL after the sketching But we are not able see the multi line text properly laid out on PDF and part of text missing. Same time Other pencil kit tools are working as expected. `func previewController(_ controller: QLPreviewController, didSaveEditedCopyOf previewItem: QLPreviewItem, at modifiedContentsURL: URL) func previewController(_ controller: QLPreviewController, didUpdateContentsOf previewItem: any QLPreviewItem)` We tested all code in iOS 18.2. Please let us know if the text edited URL on PDF can be retrieved in any possible way without tampering text
0
0
376
Feb ’25
The issue of unable to use document type for Mac catalyst project
Hello, I have encountered a question that I hope to receive an answer to. Currently, I am working on a music project for Mac Catalyst and need to enable music files such as FLAC to be opened by right clicking to view my Mac Catalyst app. But currently, I have encountered a problem where I can see my app option in the right-click open mode after debugging the newly created macOS project using the following configuration. But when I created an iOS project and converted it to a Mac Catalyst app, and then modified the info.plist with the same configuration, I couldn't see my app in the open mode after debugging. May I ask how to solve this problem? Do I need to configure any permissions or features in the Mac Catalyst project? I have been searching for a long time but have not found a solution regarding it. Please resolve it, thank you. Here is the configuration of my macOS project: CFBundleDocumentTypes CFBundleTypeExtensions flac CFBundleTypeIconSystemGenerated 1 CFBundleTypeName FLAC Audio File CFBundleTypeRole Viewer LSHandlerRank Default Note: Sandbox permissions have been enabled for both the macOS project and the iOS to Mac Catalyst project. The Mac Catalyst project also has additional permissions for com. apple. security. files. user taught. read write
0
0
77
Mar ’25
Disabling App Clip's Initial App Store Notification Banner
We're encountering a UX challenge with the automatic App Store notification banner that appears when users first launch our App Clips (not the App Clip sheet). This notification, which suggests downloading the full app, is creating confusion among our users. We've observed that some users tap the notification instead of completing their intended action within the App Clip, interrupting their workflow. Is there a way to disable this banner?
0
1
350
Jan ’25
Custom keypad touchUpInside events not working in iOS18
I have a custom keypad to accept numeric input for iPads that I have been using for many years now. This is longstanding working code. With iOS 18 the touchUpInside (and other) events in the underlying Objective-C modules are not called in the file owner module when activated from the interface. The buttons seem to be properly activated based on the visual cues (they change colors when pressed). This is occurring in both simulators and on hardware. Setting the target OS version does not help. What could the cause and/or solution of this be?
0
0
67
Mar ’25
Can't join current Group Activity on macOS (maybe some launch services thing?)
I'm testing using Group Activities and having no trouble iOS<->iOS or starting an activity on macOS and joining via iOS. However, when I start an activity and then try to join it from another macOS client, the starting side joins the session just fine, but the receiving side acts like I don't have the required app, even when it is already running. I see the active SharePlay icon in the menu bar, and the Current Activity is shown, but instead of an "Open" button there is a "MyApp Required" string and a "View" button that goes to the App Store. (Where the app is not available yet, as expected, since I'm still working on it.) There is no GroupSession started on that Mac yet, obviously. I'm looking for any hints to help debug what is going on. How does Group Activities find the app for the activity on macOS and how can I figure out why it isn't finding mine? Thanks!
0
0
328
Feb ’25
How to determine which ui control is found first in the view hierarchy, when I assign the same keyboardShortcut () to 2 buttons?
import SwiftUI struct ContentView: View { var body: some View { VStack { Button ("Button 1") { print ("Button 1"); } .keyboardShortcut("k", modifiers: .command) Button ("Button 2") { print ("Button 2"); } .keyboardShortcut("k", modifiers: .command) } } } I the above snippet, I have assigned the same keyboard shortcut (cmd +k) to 2 different buttons. According to the docs, if multiple controls are associated with the same shortcut, the first one found is used. How do I figure out if Button 1 would be found first during the traversal or Button 2 ? Is it based on the order of declaration? Is it always the case that Button 1 would be found first since it was declared before Button 2 ?
0
0
95
Mar ’25