Construct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.

Posts under UIKit tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

UIPrintPageRenderer hangs app after iPhone update
After updating iPhone from 17.4 to 17.5.1 UIPrintPageRenderer completely hangs app when getting NumberOfPages from Renderer. var render = new UIPrintPageRenderer(); if (webViewPages != null && reportIndex < webViewPages.Length) { render.AddPrintFormatter( webViewPages[reportIndex].ViewPrintFormatter, 0); } else { render.AddPrintFormatter( new UIMarkupTextPrintFormatter(reportContent), 0); } var printable = CoreGraphics.CGRectExtensions.Inset(page, 0, 0); render.SetValueForKey(NSValue.FromCGRect(page), new NSString("paperRect")); render.SetValueForKey(NSValue.FromCGRect(printable), new NSString("printableRect")); var pdfData = new NSMutableData(); UIGraphics.BeginPDFContext(pdfData, page, null); int pageNum = 0; for (pageNum = 0; pageNum < render.NumberOfPages; pageNum++) { UIGraphics.BeginPDFPage(); var bounds = UIGraphics.PDFContextBounds; render.DrawPage(pageNum, bounds); } UIGraphics.EndPDFContext();
0
0
27
6h
When using UIView.drawHierarchy, older CPU performs far better than newer CPU
Hi all, My app uses SpriteKit views which are rendered into images for various uses. For some reason, the same code performs worse on a newer CPU than on an older one. My A13 Bionic flies through the task at high resolution and 60FPS while CPU usage is <60%, while the A15 Bionic chokes and sputters at a lower resolution and 30FPS. Because of how counterintuitive this is, it took me a while to isolate the call directly responsible--with UIView.drawHierarchy commented out, both devices returned to their baseline performances. guard let sceneView = skScene.view else { return } let size = CGSize(width: outputResolution, height: outputResolution) return UIGraphicsImageRenderer(size: size).image { context in let rect = CGRect(origin: .zero, size: size) sceneView.drawHierarchy(in: rect, afterScreenUpdates: false) } Does anyone know why this is the case, and how to fix it? I tried using UIView.snapshotView, which is supposedly much faster, but it only returns blank images. Am I using it wrong or does it simply not work in this context? sceneView.snapshotView(afterScreenUpdates: false)?.draw(rect) Any hints or pointers would be greatly appreciated
0
0
27
6h
Disable new tab bar look
Hi, I am trying out the new UITabBar stuff in iOS18, and I don't think it'll be a good fit for my app. Is there a way to revert to the old iPad UITabBar look and placement that we've been using before? I don't want to make such a big change like this just yet, but I would need to make other changes to the app as well and I don't want to use the new UITabBar just yet. Is there a way to achieve this?
7
1
214
6h
Crashed iOS app at CA::Transaction::commit()
Our on field app is facing significant crashes at CA::Transaction::commit() from QuartzCore. The crash report does not point to any code in our app and the information available is very limited. It's a EXC_BAD_ACCESS KERN_INVALID_ADDRESS crash. We have tried using sanitisers and zombies but unable to reproduce the crash locally. Can someone help explain and point in right direction? Below are the crash details. Full crash report Distributor ID: com.apple.AppStore Hardware Model: iPhone15,3 AppStoreTools: 15F31e AppVariant: 1:iPhone15,3:16 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Date/Time: 2024-06-03 20:41:59.3315 +0530 Launch Time: 2024-06-03 19:15:20.6051 +0530 OS Version: iPhone OS 17.4.1 (21E236) Release Type: User Baseband Version: 2.51.04 Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000110 Exception Codes: 0x0000000000000001, 0x0000000000000110 VM Region Info: 0x110 is not in any region. Bytes before following region: 4372119280 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 104994000-105420000 [ 10.5M] r-x/r-x SM=COW /var/containers/Bundle/Application/ Termination Reason: SIGNAL 11 Segmentation fault: 11 Terminating Process: exc handler [35195] Triggered by Thread: 0 Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter Thread 0 name: Thread 0 Crashed: 0 QuartzCore 0x000000018f4633b4 CA::Transaction::commit() + 1152 (CATransactionInternal.mm:480) 1 QuartzCore 0x000000018f4633ec CA::Transaction::commit() + 1208 (CATransactionInternal.mm:480) 2 QuartzCore 0x000000018f462e64 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:942) 3 UIKitCore 0x00000001900b1260 _UIApplicationFlushCATransaction + 52 (UIApplication.m:3160) 4 UIKitCore 0x00000001900b0d78 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:119) 5 UIKitCore 0x00000001900b0468 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1037) 6 UIKitCore 0x00000001900b0524 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1186) 7 CoreFoundation 0x000000018ddc162c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957) 8 CoreFoundation 0x000000018ddc08a8 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001) 9 CoreFoundation 0x000000018ddbf0b8 __CFRunLoopDoSources0 + 340 (CFRunLoop.c:2046) 10 CoreFoundation 0x000000018ddbdd88 __CFRunLoopRun + 828 (CFRunLoop.c:2955) 11 CoreFoundation 0x000000018ddbd968 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420) 12 GraphicsServices 0x00000001d20b34e0 GSEventRunModal + 164 (GSEvent.c:2196) 13 UIKitCore 0x0000000190230edc -[UIApplication _run] + 888 (UIApplication.m:3692) 14 UIKitCore 0x0000000190230518 UIApplicationMain + 340 (UIApplication.m:5282) 15 AppName 0x000000010542072c main + 64 (AppDelegate.swift:13) 16 dyld 0x00000001b12ded84 start + 2240 (dyldMain.cpp:1298)
0
0
17
9h
SwiftUI popover not respecting arrow direction
When I try to change the arrow direction for SwiftUI popover it's not working at all, but in UIKit it seems to be ok Please check the sample code Button { showPopover.toggle() } label: { Text("Show Popover") .padding(60) .border(Color.yellow) } .popover( isPresented: $showPopover, arrowEdge: .bottom // issue here ) { Text("Popover conent") }
2
0
74
17h
How to interact during the Transition process?(wwdc24 UIKit consultation)
Recently I tried to apply a custom transition to a custom contextMenu. However, I want to make sure that during the transition process (which is not over yet), my contextMenu elements such as buttons can be tapped. But I tried a lot of things without success. I know you have a lot of experience, so I would like to ask you about how to implement the transition and be able to interact before it is over. I know that a UIView can be tapped during animation, but I haven't tried the button in a UIView. I've been trying to transition ViewControllers. For example, in a transition from fromViewController to toViewController, I wanted to be able to tap on a tableView in toViewController during the transition, but I was frustrated and found it very difficult to implement. I would like to ask you about the possibilities of interaction during the Viewcontrollers transition. (PS: In Github Issues, I uploaded a GIF example of the plus button on the left of the input box in iMessage. After tapping the plus button, you can tap the "Apple Cash" button before the transition is finished.) Your advice would be incredibly valuable to me. Thank you in advance for your time and assistance. [GithubLink]https://github.com/Juhnkerg/DemoForInteractionDuringTransition)
0
0
46
21h
How to avoid Swift 6 concurrency warning from UIAccessibility.post()
I have the following var in an @Observable class: var displayResult: String { if let currentResult = currentResult, let decimalResult = Decimal(string: currentResult) { let result = decimalResult.formatForDisplay() UIAccessibility.post(notification: .announcement, argument: "Current result \(result)") return result } else { return "0" } } The UIAccessiblity.post gives me this warning: Reference to static property 'announcement' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6 How can I avoid this?
2
0
77
1d
New Sliders
For the past couple of years, Apple has been using custom sliders in Music, Podcasts, and on the Lock Screen for scrubbing music and controlling volume. But those sliders are not available to 3rd party devs. We can recreate them theoretically for scrubbing audio. But not for volume, where in UIKit we are supposed to use MPVolumeView. Anyone from Apple? Are there any plans to make the slider styles used in Apple's audio apps available to the rest of us? FB12261162
0
0
42
1d
UIDevice: Main actor-isolated class property 'current' can not be referenced from a non-isolated context
I have a Safari Web Extension for visionOS that reads from UIDevice.current.systemVersion in order to provide the OS version number back to the JavaScript context utilizing beginRequest(with:). When switching my project to use Swift 6, I received this obscure error: Main actor-isolated class property 'current' can not be referenced from a non-isolated context Class property declared here (UIKit.UIDevice) Add '@MainActor' to make instance method 'beginRequest(with:)' part of global actor 'MainActor' Adding @MainActor causes another issue (Main actor-isolated instance method 'beginRequest(with:)' cannot be used to satisfy nonisolated protocol requirement) which suggests adding @preconcurrency to NSExtensionRequestHandling which then breaks at Non-sendable type 'NSExtensionContext' in parameter of the protocol requirement satisfied by main actor-isolated instance method 'beginRequest(with:)' cannot cross actor boundary. What's the proper solution here? Here's a simplified snippet of my code: class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { func beginRequest(with context: NSExtensionContext) { // ... var systemVersionNumber = "" systemVersionNumber = UIDevice.current.systemVersion // ... } }
1
0
140
1d
iOS 18 developer beta: Writing Tools
Based on the session content, it seems that setting the TextView property writingToolsBehavior = .complete should bring up the writing tools bottom panel view. However, it does not appear to be working. Is this a feature that will be added in a future update, or is there something additional I need to do? Test on: XCode 16.0 beta (16A5171c), iOS Simulator 18.0 Beta, iPhone 11 Pro iOS 18.0 Beta
2
3
97
1d
Custom Domain deeplink
My SampleApp, named "myApp," already supports deep links such as "https://myApp.com/tab/record/10020." When this link is clicked, it navigates to myApp, and AppDelegate handles the further process. Now, I need to support another link (domain), "https://appcloud.com/tab/record/10020," so that clicking this link also navigates to myApp. Is there any way to solve this kind of problem without adding "apple-app-site-association"?
1
0
67
1d
UIKit ContactsAccessButton?
Apple revealed the ContactsAccessButton in the WWDC24 session 10121: Meet the Contact Access Button. After watching the video, reading through the documentation as well as the sample code , I can only find a SwiftUI ContactsAccessButton. However, our code base is written largely in UIKit, and our team prefers to do complex work and customization with lists via UITableView as opposed to SwiftUI List. So we would greatly prefer to use a UIKit ContactAccessButton. Is there not a UIKit equivalent to ContactsAccessButton? If there is, where can we find it?
1
0
66
1d
iOS18Bate导航栏
代码如下 (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBar.translucent = NO; } (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:true]; } 此时加载VC时顶部会出现空白,整个VC的frame的Y值向下偏移了状态栏的高度,再次切换到此VC则会恢复,这是iOS18Bate的bug吗
0
0
34
1d
The application crashes in the App Store when launch on iPhone with iOS 15.3.1.
My application is currently crashing in production in iPhone devices running iOS 15.x. The app will work as normal while running developer mode, enterprise builds and Test Flight builds. Unfortunately, I am unable to reproduce this issue even app is downloaded from the app store. I observed crash is happening at main.m. Can someone help me to reproduce this issue? How to read this crash log file? Please find the crash log details attached. 2022-03-04_14-15-23.6227_+0900-a1899fd803a4ed683466702be71b9d224b4cd5bc.crash
3
1
2.4k
1d
self.edgesForExtendedLayout=UIRectEdgeNone ios18beta move UIView down
Using the UINavigationController, jump from page A(UIViewController A) to page B (UIViewController B), and page B(UIViewController B) clicks back. When page A(UIViewController A) is returned, the view of page A(UIViewController A) moves down as a whole, and the top turns black. Reproduce steps: step1: Set “self.edgesForExtendedLayout = UIRectEdgeNone;” in the method “viewDidLoad” UIViewController - (void)viewDidLoad { [super viewDidLoad]; // step1 self.edgesForExtendedLayout = UIRectEdgeNone; } step2:Set “ self.navigationController.navigationBarHidden = YES;” in the method “viewWillAppear” UIViewController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // step2 self.navigationController.navigationBarHidden = YES; } step3:Set “self.navigationController.navigationBarHidden = NO;” in the method “viewWillDisappear” UIViewController - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // step3 self.navigationController.navigationBarHidden = NO; } step4:Set “[self.navigationControllerpopViewControllerAnimated:NO];” in the method “viewWillDisappear” UIViewController When page is returned - (void)click { UIViewController *vc = [[UIViewController alloc] init]; vc.view.backgroundColor = [UIColor redColor]; [self.navigationController pushViewController:vc animated:YES]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // step4,animated NO [self.navigationController popViewControllerAnimated:NO]; }); } The test found that the UIView was normal after removing the "self.edgesForExtendedLayout=UIRectEdgeNone" setting.
0
0
53
1d
UIDocumentViewController based app built for iOS 17.5 unexpectedly uses new document launch experience under iOS 18 developer beta
In the WWDC24 session Evolve your document launch experience, it is mentioned that apps linked against the iOS 17 SDK would not get the new document launch experience. However, I found that the new document browser is active in my iOS 17 app when installed from the App Store on iOS 18, without rebuilding it. This (along with other iOS 18 UIKit behavioral regressions) renders the app unusable when running under iOS 18. To be clear, my app uses a UIDocumentViewController as the root view controller of a UINavigationController and is implemented primarily in Obj-C. I don't want to show the new document browser to users at app launch time. The current behavior of my app is that it always launches to either the current document or a new document and then allows the user to open a new document using the document picker if desired (this was accomplished by invoking the action associated with the Documents button on iOS 17; see related feedback FB13418866: ER: UIDocumentViewController should provide API to allow customization of Documents button behavior). The new UIDocumentViewController behavior is problematic because it has replaced the Documents button with a backAction that moves the user into the new document browser with no way to back out, aside from picking a document or creating a new document. Previously, the user could choose Cancel to exit the document picker and get back to the currently-open document without choosing a new one. While the new UIDocumentViewController behavior looks nice for apps like Swift Playgrounds, it is problematic for apps that want to take advantage of the UIDocument infrastructure without forcing the user to deal with a more complicated browser-centric app UI. I would expect there to be some way to maintain the previous behavior as it existed on iOS 17, but I don't see any way to do this. Suggestions welcome. Thanks!
4
0
112
1d
iOS 18 beta REGRESSION: UIDocumentViewController is no longer in responder chain for title menu item actions?
In testing my app with the WWDC24 iOS 18 beta, I have noticed that most of the menu items in the navigation bar and title menu are either missing, disabled, or nonfunctional. The structure of my app's UI is a UIDocumentController subclass as the root view controller of a UINavigationController. In debugging the problem with title menu items, I noticed that the responder chain from the UICommand.sender now starts at the UINavigationBar and goes up from there, without passing through the UIDocumentViewController itself. Now, only the actions I've defined in the AppDelegate are accessible. I'm not exactly sure how this was organized on iOS 17, but the responder chain did include the UIDocumentViewController, where I have implemented most of the menu item actions. This seems like a UIKit bug, but I am investigating possible workarounds in case Apple does not fix it. Suggestions welcome.
4
0
131
1d
Deinitializer won't get called
I'm presenting a view controller inside a UIAction handler from the new UIButton init configuration API. But when I do it, its deinit won't get called. I'm thinking there's some sort of retain cycle? I've tried capturing [weak self] inside the closure with no success. Using the addTarget method instead, the deinit gets called as expected. What am I doing wrong? let testVC = TestViewController() lazy var testButton: UIButton = { var configuration = UIButton.Configuration.filled() //button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) let button = UIButton(configuration: configuration, primaryAction: UIAction(handler: { action in self.present(testVC, animated: true, completion: nil) })) return button }()
1
0
243
1d