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

UIDocumentPickerViewController
I'm upgrading my app from minVersion iOS 11 to iOS 12. My compiler says that UIDocumentMenuViewController with UIDocumentPickerViewController is deprecated, they recommend to use directly the last one. So I change the code. fileprivate func openDocumentPicker() { let documentPicker = UIDocumentPickerViewController( documentTypes: [ "com.adobe.pdf", "org.openxmlformats.wordprocessingml.document", // DOCX "com.microsoft.word.doc" // DOC ], in: .import ) documentPicker.delegate = self view.window?.rootViewController?.present(documentPicker, animated: true, completion: nil) } When I open the picker in iOS 17.2 simulator and under it is well shown, like a page sheet. But in iOS 18.0 and up at first it opens like a page sheet with no content but then it is displayed as a transparent window with no content. Is there any issue with this component and iOS 18? If I open the picker through UIDocumentMenuViewControllerDelegate in an iphone with iOS 18.2 it is well shown. Image in iOS 18.2 with the snippet The same snippet in iOS 17.2 (and expected in older ones)
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
359
Jan ’25
Translate extension bahvior
DESCRIPTION OF PROBLEM We need to add an implementation that will have the same swipe/scroll behavior as the Apple Translator extension, here is the code that we are currently using: import SwiftUI import TranslationUIProvider @main class TranslationProviderExtension: TranslationUIProviderExtension { required init() {} var body: some TranslationUIProviderExtensionScene { TranslationUIProviderSelectedTextScene { context in VStack { TranslationProviderView(context: context) } } } } struct TranslationProviderView: View { @State var context: TranslationUIProviderContext init(context c: TranslationUIProviderContext) { context = c } var body: some View { ScrollableSheetView() } } struct ScrollableSheetView: View { var body: some View { ScrollView { VStack(spacing: 20) { ForEach(0..<50) { index in Text("Item (index)") .padding() .frame(maxWidth: .infinity) .background(Color.blue.opacity(0.1)) .cornerRadius(8) } } .padding() } .padding() } } Using this code, on the first extension run, swipe up will expand the extension (which is OK) but swiping down on the expanded state of the extension works only as a scroll instead of swiping the extension from expanded mode back to compact mode. STEPS TO REPRODUCE Select a text in Safari Tap on Translate in the contextual menu Swipe up on the text ->the extension expands into full mode Swipe down->only scrolls work, I cannot swipe the extension from full mode to compact mode. Expected behavior: when i swipe down on the expanded extension, the extension should get into compact mode, not continuously scroll down.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
67
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
Inconsistent ornament scale
I am developing an application which make use of 2 ornaments anchored to a volumetric window, one used a toolbar and one to display different views. The problem I am facing consistently is that the ornaments seems to scale up or down after moving the volume using the OS handle or starting a GroupActivity session. This first image shows the ornaments as soon as I started the app, no dragging nor group activities: This second images shows them as soon as I join a group activity session: The map, which might seem smaller, has not been touched and has always the same scale. In this last image I had just dragged the entire volume using the OS toolbar, resulting in the ornaments scaling down: This is how the volume and the ornaments are declared: WindowGroup(id: "CityVolume") { let cityVM = CityViewModel(volumeSize: CityView.initialVolumeSize) CityView(cityVM: cityVM) .ornament(attachmentAnchor: .scene(.bottomFront)) { HStack { TourismChartsButton() LandmarksListButton() CenterMapButton() ToggleImmersiveSpaceButton() TrafficDataButton() BusLinesButton() } .padding() .offset(z: 10) .rotation3DEffect(Angle(degrees: 15), axis: (x: 1.0, y: 0.0, z: 0.0)) } .ornament(attachmentAnchor: .scene(.back)) { ZStack { if AppModel.Instance.tourismVM.isChartViewVisible { TourismChartsView() } if AppModel.Instance.busLinesVM.isDataViewEnabled { BusLineView() } } } .task(observeGroupActivity) .onAppear { appModel.cityVM = cityVM } } .windowStyle(.volumetric) .windowResizability(.contentSize) .volumeWorldAlignment(.gravityAligned) .defaultSize(CityView.initialVolumeSize, in: .meters) It happens also without starting a SharePlay session, but not as frequently as during SharePlay. Experienced the same behaviour with toolbars. Am I doing something wrong with how I created the ornaments? Am I missing something?
0
0
95
Apr ’25
drag a modelEntity inside an Immersive space and track position
Goal : Drag a sphere across the room and track it's position Problem: The gesture seems to have no effect on the sphere ModelEntity. I don't know how to properly attach the gesture to the ModelEntity. Any help is great. Thank you import SwiftUI import RealityKit import RealityKitContent import Foundation @main struct testApp: App { @State var immersionStyle:ImmersionStyle = .mixed var body: some Scene { ImmersiveSpace { ContentView() } .immersionStyle(selection: $immersionStyle, in: .mixed, .full, .progressive) } } struct ContentView: View { @State private var lastPosition: SIMD3<Float>? = nil @State var subscription: EventSubscription? @State private var isDragging: Bool = false var sphere: ModelEntity { let mesh = MeshResource.generateSphere(radius: 0.05) let material = SimpleMaterial(color: .blue, isMetallic: false) let entity = ModelEntity(mesh: mesh, materials: [material]) entity.generateCollisionShapes(recursive: true) return entity } var drag: some Gesture { DragGesture() .targetedToEntity(sphere) .onChanged { _ in self.isDragging = true } .onEnded { _ in self.isDragging = false } } var body: some View { Text("Hello, World!") RealityView { content in //1. Anchor Entity let anchor = AnchorEntity(world: SIMD3<Float>(0, 0, -1)) let ball = sphere //1.2 add component to ball ball.components.set(InputTargetComponent()) //2. add anchor to sphere anchor.addChild(ball) content.add(anchor) subscription = content.subscribe(to: SceneEvents.Update.self) { event in let currentPosition = ball.position(relativeTo: nil) if let last = lastPosition, last != currentPosition { print("Sphere moved from \(last) to \(currentPosition)") } lastPosition = currentPosition } } .gesture(drag) } }
0
0
62
Apr ’25
Navbar buttons disappear in NavigationSplitView's sidebar when changing apps
We recently migrated our app to use NavigationSplitView on iPad with a sidebar and detail setup, and we got reports that the navigation buttons on the sidebar disappear when returning to our app after using a different app. I reproduced the issue from a new empty project with the following code (issue tested on iOS 17.4 and iOS 18.3, was not able to reproduce on iOS 16.4): import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { NavigationSplitView { Text("sidebar") .toolbar { ToolbarItem(placement: .topBarLeading) { Button(action: {}) { Image(systemName: "square.and.arrow.down") } } ToolbarItem(placement: .topBarTrailing) { Button(action: {}) { Image(systemName: "square.and.arrow.up") } } } } detail: { Text("detail") .toolbar { ToolbarItem(placement: .topBarLeading) { Button(action: {}) { Image(systemName: "eraser") } } ToolbarItem(placement: .topBarTrailing) { Button(action: {}) { Image(systemName: "pencil") } } } } } } } Please check the following GIF for the simple steps, notice how the navbar buttons in the detail view do not disappear: Here's the console output, it shows that the constraints break internally:
0
0
111
Apr ’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
Replaykit stop screen record failed, recording status is false
I want to record screen ,and than when I call the method stopCaptureWithHandler:(nullable void (^)(NSError *_Nullable error))handler to stop recording and saving file. before call it,I check the value record of RPScreenRecorder sharedRecorder ,the value is false , It's weird! The screen is currently being recorded ! I wonder if the value of [RPScreenRecorder sharedRecorder].record will affect the method stopCaptureWithHandler: -(void)startCaptureScreen { [[RPScreenRecorder sharedRecorder] startCaptureWithHandler:^(CMSampleBufferRef _Nonnull sampleBuffer, RPSampleBufferType bufferType, NSError * _Nullable error) { //code } completionHandler:^(NSError * _Nullable error) { //code }]; } - (void)stopRecordingHandler { if([[RPScreenRecorder sharedRecorder] isRecording]){ // deal error .sometime isRecording is false }else { [[RPScreenRecorder sharedRecorder] stopCaptureWithHandler:^(NSError * _Nullable error) { }]; } } here are my code.
0
0
85
Apr ’25
iOS 18 SDK causing random UI changes and crashes with my app
I am a developer on an enterprise application. Our team just updated our pipeline to build our app on the iOS 18 SDK instead of the 17.4 SDK and this has caused a lot of our ui elements to change and several crashes within the app resulting in just the simple error message "Swift runtime failure: unhandled C++ / Objective-C exception". Why is just updating the SDK causing all these issues? Is there anyway to keep the previous version or will we have to go component by component to fix the constraints and crashes? These issues seem to be happening to our users on iOS 18 and beyond.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
124
Apr ’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
356
Jan ’25
NearbyInteraction with Live Activity and background behavior on iOS 18.4 / watchOS – Questions on UWB and Audio
Hi everyone, we’d appreciate your input on the following use case – thanks in advance! In our iPhone and Apple Watch app, we’re using the NearbyInteraction API to measure the distance between both devices via UWB. Setup: On the iPhone, we start a LiveActivity together with the NISession, to keep the ranging active in the background. ✅ Good news: On iOS 18.4, this works as expected – the NISession stays active in the background as long as the Live Activity is running. Current issues: As soon as the Watch app moves to the background, ranging seems to pause and is eventually terminated. → Question 1: Is there a way to keep the NISession active on the Watch when the app goes into the background? Audio playback from background not working: We'd like to trigger audio playback when certain distance changes are detected. So far, we can only trigger haptic feedback in the background – audio does not play. → Question 2: Is it possible to play audio (e.g. using AVAudioPlayer) while a NISession and a LiveActivity are running in the background? We’d be grateful for any advice or best practices for this combination. Thanks and best regards!
Topic: UI Frameworks SubTopic: General
0
0
58
May ’25
UICollectionView Dequeue Crash Xcode 16.2
I am facing same issue with major crash while coming out from this function. Basically using collectionView.dequeReusableCell with size calculation. func getSizeOfFavouriteCell(_ collectionView: UICollectionView, at indexPath: IndexPath, item: FindCircleInfoCellItem) -> CGSize { guard let dummyCell = collectionView.dequeueReusableCell( withReuseIdentifier: TAButtonAddCollectionViewCell.reuseIdentifier, for: indexPath) as? TAButtonAddCollectionViewCell else { return CGSize.zero } dummyCell.title = item.title dummyCell.subtitle = item.subtitle dummyCell.icon = item.icon dummyCell.layoutIfNeeded() var targetSize = CGSize.zero if viewModel.favoritesDataSource.isEmpty.not, viewModel.favoritesDataSource.count > FindSheetViewControllerConstants.minimumFavoritesToDisplayInSection { targetSize = CGSize(width: collectionView.frame.size.width / 2, height: collectionView.frame.height) var estimatedSize: CGSize = dummyCell.systemLayoutSizeFitting(targetSize) if estimatedSize.width > targetSize.width { estimatedSize.width = targetSize.width } return CGSize(width: estimatedSize.width, height: targetSize.height) } } We have resolve issue with size calculation with checking nil. Working fine in xcode 15 and 16+. Note: Please help me with reason of crash? Is it because of xCode 16.2 onwards **strict check on UICollectionView **
0
0
136
Apr ’25
Trigger save of a FileDocument in a DocumentGroup?
I have a DocumentGroup working with a FileDocument, and that's fine. However, when someone creates a new document I want them to have to immediately save it. This is the behavior on ipadOS and iOS from what I can understand (you select where before the file is created). There seems to be no way to do this on macOS? I basically want to have someone: create a new document enter some basic data hit "create" which saves the file then lets the user start editing it (1), (2), and (4) are done and fairly trivial. (3) seems impossible, though...? This really only needs to support macOS but any pointers would be appreciated.
0
0
119
Apr ’25
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
120
Apr ’25
How to remove margins around built-in views?
I want to have my own background and foreground colors for some views and I am having a bit of trouble. I cannot figure out how to remove the margins around some built-in views. One example is below. The ScrollView portion is always black or white, depending on whether I am I dark mode or not. I've added various colors and borders to see what is going on below. I've also tried adding the modifiers to the Scroll View rather than the TextEditor and it doesn't work at all. If I don't have the .frame modifier on the ScrollView, the TextEditor moves to the top of its frame for some reason. I've played with .contentMargins, .edgeInsets, etc. with no luck How do I get the TextEditor to fill the entire ScrollView without the margin? Thanks! import SwiftUI struct TextEditorView: View { @Binding var editString: String var numberOfLines: Int var lineHeight: CGFloat { UIFont.preferredFont(forTextStyle: .body).lineHeight } var viewHeight: CGFloat { lineHeight * CGFloat(numberOfLines) + 8 } var body: some View { ScrollView([.vertical], showsIndicators: true) { TextEditor(text: $editString) .border(Color.red, width: 5) .foregroundStyle(.yellow) .background(.blue) .frame(minHeight:viewHeight, maxHeight: viewHeight) .scrollContentBackground(.hidden) } .frame(minHeight:viewHeight, maxHeight: viewHeight) } }
0
0
198
Jan ’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
380
Feb ’25
Longtime UIStackView Bug
There has been a long lasting UIStackView bug dating back to 2016 that still exists in the latest Xcode 16.3 and SDKs, where calling setHidden:true multiple times (lets say twice) on a subview of that stack view requires calling setHidden:false twice before the subview shows up again. This was originally documented via Radar #25087688. Hopefully a Frameworks Engineer here on the forums can raise it to the attention of the appropriate engineers. It would be really nice if this eventually gets fixed, because it's one of those odd issues where you end up wasting a lot of time trying to debug because everything looks correct.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
1
78
Apr ’25