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

Posts under UIKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

AVPlayer loading performance problem in iOS 26
Hi, I have an app that displays tens of short (<1mb) mp4 videos stored in a remote server in a vertical UICollectionView that has horizontally scrollable sections. I'm caching all mp4 files on disk after downloading, and I also have a in-memory cache that holds a limited number (around 30) of players. The players I'm using are simple views that wrap an AVPlayerLayer and its AVPlayerItem, along with a few additional UI components. The scrolling performance was good before iOS 26, but with the release of iOS 26, I noticed that there is significant stuttering during scrolling while creating players with a fileUrl. It happens even if use the same video file cached on disk for each cell for testing. I also started getting this kind of log messages after the players are deinitialized: <<<< PlayerRemoteXPC >>>> signalled err=-12785 at <>:1107 <<<< PlayerRemoteXPC >>>> signalled err=-12785 at <>:1095 <<<< PlayerRemoteXPC >>>> signalled err=-12785 at <>:1095 There's also another log message that I see occasionally, but I don't know what triggers it. << FigXPC >> signalled err=-16152 at <>:1683 Is there anyone else that experienced this kind of problem with the latest release? Also, I'm wondering what's the best way to resolve the issue. I could increase the size of the memory cache to something large like 100, but I'm not sure if it is an acceptable solution because: 1- There will be 100 player instance in memory at all times. 2- There will still be stuttering during the initial loading of the videos from the web. Any help is appreciated!
0
0
197
Sep ’25
preferredTransition not working when using setViewControllers(_:animated:)
I’m using the new preferredTransition = .zoom(...) API introduced in iOS 18. Here’s a simplified version of what I do on app startup: let listVC = CollectionViewController(collectionViewLayout: layout) let detailVC = DetailViewController() detailVC.preferredTransition = .zoom(sourceViewProvider: { context in let indexPath = IndexPath(row: 0, section: 0) let cell = listVC.collectionView.cellForItem(at: indexPath) return cell }) let nav = UINavigationController() nav.setViewControllers([listVC, detailVC], animated: false) window?.rootViewController = nav window?.makeKeyAndVisible() This is meant to restore the UI state from a previous session — the app should launch directly into the DetailViewController. The Problem When I launch the app with setViewControllers([listVC, detailVC], animated: false), the transition from listVC to detailVC appears correctly (i.e., no animation, as intended), but the drag-to-dismiss gesture does not work. The back button appears, and tapping it correctly triggers the zoom-out transition back to the cell, so the preferredTransition = .zoom(...) itself is properly configured. Interestingly, if I delay the push with a DispatchQueue.main.async and instead do: nav.setViewControllers([listVC], animated: false) DispatchQueue.main.async { nav.pushViewController(detailVC, animated: true) } …then everything works perfectly — including the interactive swipe-to-dismiss gesture — but that introduces an unwanted visual artifact: the user briefly sees the listVC, and then it pushes to detailVC, which I’m trying to avoid. My Question Is there a way to enable the swipe-to-dismiss gesture when using setViewControllers([listVC, detailVC], animated: false) It can be very confusing for users if swipe-to-dismiss only works in certain cases inconsistently. Thanks
6
0
280
Sep ’25
iOS 26: UITabBarItem.isEnabled = false no longer prevents selection (works on iOS 18)
Code that disables a tab bar item via UITabBarItem.isEnabled = false used to both grey out the item and block taps on iOS 18. On iOS 26, the item often remains tappable and selectable, even though isEnabled is set to false. This looks like a behavior change or regression. func disableTabbarItems(tabbar: UITabBarController, isEnable: Bool, index: Int) { if let tabItems = tabbar.tabBar.items, index < tabItems.count { let tabItem = tabItems[index] tabItem.isEnabled = isEnable } } iOS 18 iOS 26
1
0
95
Sep ’25
iOS 26: UITabBarItem.isEnabled = false no longer prevents selection (works on iOS 18)
Code that disables a tab bar item via UITabBarItem.isEnabled = false used to both grey out the item and block taps on iOS 18. On iOS 26, the item often remains tappable and selectable, even though isEnabled is set to false. This looks like a behavior change or regression. func disableTabbarItems(tabbar: UITabBarController, isEnable: Bool, index: Int) { if let tabItems = tabbar.tabBar.items { let tabItem = tabItems[index] tabItem.isEnabled = isEnable } ![]("https://developer.apple.com/forums/content/attachment/a3c0bafb-2b10-44c3-8d76-d31bd83f30f7" "title=iOS 18.jpg;width=1179;height=279") } ![]("https://developer.apple.com/forums/content/attachment/4bbaccf3-292b-4790-b272-0d9809ba2949" "title=iOS 26.jpg;width=828;height=196")
0
0
25
Sep ’25
keyboard crash
My app encountered a crash problem. The analysis stack seems to be related to the keyboard. The system keyboard code is unresponsive for a long time until it crash. The feature of the stack, BrowserEngineKit, seems to indicate the webview scene. Xcode debugging found that tap the input box on the webview page can reproduce the same stack as the crash, but the crash cannot be reproduced. I noticed a feedback link https://developer.apple.com/forums/thread/784718, which is the same as the top of the crash stack I encountered, so the root cause of the problem may be similar, caused by the locking operation related to UIKeyboardTaskQueue. Hope to give some suggestions. Thanks. crash log: Incident Identifier: 39E3AFE6-43B1-4DE6-AC2B-D62C5EC89752 CrashReporter Key: AppleMetricKit Hardware Model: iPhone17,2 Process: iAliexpress Code Type: ARM-64 Parent Process: ? [1] Date/Time: 2025-07-02 22:59:00 Launch Time: Unknown OS Version: iPhone OS 18.1.1 (22B91) Report Version: 104 Exception Type: EXC_CRASH Exception Codes: KERN_SUCCESS Triggered by Thread: 0 Application Specific Information: &lt;RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: app&lt;com.alibaba.iAliexpress(A182346C-2A09-4082-9AAE-0EC7A1A1B5AB)&gt;:2263 exhausted real (wall clock) time allowance of 10.00 seconds ProcessVisibility: Unknown ProcessState: Running WatchdogEvent: scene-update WatchdogVisibility: Background WatchdogCPUStatistics: ( "Elapsed total CPU time (seconds): 15.280 (user 9.430, system 5.850), 25% CPU", "Elapsed application CPU time (seconds): 0.210, 0% CPU" ) reportType:CrashLog maxTerminationResistance:Interactive&gt; Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001ea7f7f90 __psynch_cvwait :8 (in libsystem_kernel.dylib) 1 libsystem_pthread.dylib 0x000000022296aa7c _pthread_cond_wait :1248 (in libsystem_pthread.dylib) 2 Foundation 0x000000019908fa9c -[NSCondition waitUntilDate:] :132 (in Foundation) 3 Foundation 0x000000019908bea8 -[NSConditionLock lockWhenCondition:beforeDate:] :80 (in Foundation) 4 UIKitCore 0x000000019d05cbb4 -[UIKeyboardTaskQueue lockWhenReadyForMainThread] :784 (in UIKitCore) 5 UIKitCore 0x000000019d05c85c -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] :160 (in UIKitCore) 6 UIKitCore 0x000000019d56720c -[_UIKeyboardStateManager prepareForSelectionChange] :128 (in UIKitCore) 7 UIKitCore 0x000000019d5674f4 -[_UIKeyboardStateManager selectionWillChange:] :72 (in UIKitCore) 8 BrowserEngineKit 0x0000000257671688 -[BETextInteraction selectionWillChange:] :84 (in BrowserEngineKit) 9 UIKitCore 0x000000019d75d654 -[UIAsyncTextInteraction selectionWillChange:] :68 (in UIKitCore) 10 UIKitCore 0x000000019dbae374 -[_UIKeyboardTextSelectionController beginSelectionChange] :64 (in UIKitCore) 11 UIKitCore 0x000000019df5fed0 -[UITextSelectionInteraction tappedToPositionCursorWithGesture:atPoint:granularity:completionHandler:] :476 (in UIKitCore) 12 UIKitCore 0x000000019df5f948 -[UITextSelectionInteraction _checkForRepeatedTap:gestureLocationOut:] :1072 (in UIKitCore) 13 UIKitCore 0x000000019df60488 -[UITextSelectionInteraction _handleMultiTapGesture:] :852 (in UIKitCore) 14 UIKitCore 0x000000019cf879cc -[UIApplication sendAction:to:from:forEvent:] :100 (in UIKitCore) 15 UIKitCore 0x000000019d84ce98 -[UITextMultiTapRecognizer onStateUpdate:] :280 (in UIKitCore) 16 UIKitCore 0x000000019cfb6ac4 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] :128 (in UIKitCore) 17 UIKitCore 0x000000019cfb6934 _UIGestureRecognizerSendTargetActions :92 (in UIKitCore) 18 UIKitCore 0x000000019cfb66f4 _UIGestureRecognizerSendActions :284 (in UIKitCore) 19 UIKitCore 0x000000019cc69b28 -[UIGestureRecognizer _updateGestureForActiveEvents] :572 (in UIKitCore) 20 UIKitCore 0x000000019cc3b724 _UIGestureEnvironmentUpdate :2488 (in UIKitCore) 21 UIKitCore 0x000000019cd2fa00 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] :336 (in UIKitCore) 22 UIKitCore 0x000000019cecffe4 -[UIGestureEnvironment _updateForEvent:window:] :188 (in UIKitCore) 23 UIKitCore 0x000000019cecf3c8 -[UIWindow sendEvent:] :2948 (in UIKitCore) 24 iAliexpress 0x0000000104e92000 -[UIWindow(AliHA) aliHASwizzledSendEvent:] UIWindow+AliHA.m:18 (in iAliexpress) 25 UIKitCore 0x000000019cd63b70 -[UIApplication sendEvent:] :376 (in UIKitCore) 26 iAliexpress 0x0000000104e91c84 -[UIApplication(SPM) alg_sendEvent:] AFSPMManager.m:0 (in iAliexpress) 27 UIKitCore 0x000000019cd6409c __dispatchPreprocessedEventFromEventQueue :1048 (in UIKitCore) 28 UIKitCore 0x000000019cd6df3c __processEventQueue :5696 (in UIKitCore) 29 UIKitCore 0x000000019cc66c60 updateCycleEntry :160 (in UIKitCore) 30 UIKitCore 0x000000019cc649d8 _UIUpdateSequenceRun :84 (in UIKitCore) 31 UIKitCore 0x000000019cc64628 schedulerStepScheduledMainSection :172 (in UIKitCore) 32 UIKitCore 0x000000019cc6559c runloopSourceCallback :92 (in UIKitCore) 33 CoreFoundation 0x000000019a434328 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ :28 (in CoreFoundation) 34 CoreFoundation 0x000000019a4342bc __CFRunLoopDoSource0 :176 (in CoreFoundation) 35 CoreFoundation 0x000000019a431dc0 __CFRunLoopDoSources0 :244 (in CoreFoundation) 36 CoreFoundation 0x000000019a430fbc __CFRunLoopRun :840 (in CoreFoundation) 37 CoreFoundation 0x000000019a430830 CFRunLoopRunSpecific :588 (in CoreFoundation) 38 GraphicsServices 0x00000001e64101c4 GSEventRunModal :164 (in GraphicsServices) 39 UIKitCore 0x000000019cf96eb0 -[UIApplication _run] :816 (in UIKitCore) 40 UIKitCore 0x000000019d0455b4 UIApplicationMain :340 (in UIKitCore) 41 iAliexpress 0x0000000104e9b0b8 _main main.m:17 (in iAliexpress) 42 dyld 0x00000001bfe1eec8 start :2724 (in dyld)
2
1
195
Sep ’25
How to differentiate between user-typed text vs programmatic calls to insertText(_:) in UITextView subclass?
Hi all, I’m subclassing UITextView and overriding insertText(_:) to intercept and log input: class TWTextView: UITextView { override func insertText(_ text: String) { print("insertText() : \(text)") super.insertText(text) } } This works fine, but I’ve noticed that insertText(_:) is invoked both when: The user types something in the text view (via hardware/software keyboard). I programmatically call myTextView.insertText("Hello") from my own code. I’d like to be able to distinguish between these two cases — i.e., know whether the call was triggered by the user or by my own programmatic insert. Is there any recommended way or system-provided signal to differentiate this? Thanks in advance!
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
67
Sep ’25
How to disable scrollToTop when clicking on selected tab
I currently have a SwiftUI TabView that has 5 Tab's. The first tab has a UIScrollView in a UIViewRepresentible with scrollView.scrollsToTop = false and that works fine for when the user hits the navigation bar, however if the user taps the first tab when it is already selected my UIScrollView scrolls to top. My UIScrollView is essentially 5 views, a center view, top, bottom, right, and left view. All views except for the center are offscreen but available for the user to scroll horizontal or vertical (and the respective views get updated based on the new center view). The issue I have is that clicking the first tab when its already selected, sets the content offset (for the y axis) to 0, which messes me up 2x, first it scrolls up but since its not really scrolling the right, left, and upper views dont exist, which makes the user think it can't be scrolled or it's broken. For now I subclassed UIScrollView like this class NoScrollToTopScrollView: UIScrollView { override func setContentOffset(_ contentOffset: CGPoint, animated: Bool) { if contentOffset.y == .zero { // Ignore SwiftUI’s re-tap scroll-to-top return } super.setContentOffset(contentOffset, animated: animated) } } which seems to work, but I'm just wondering if there is a better way to do this, or maybe a way to disable SwiftUI Tab from doing its default action which can help with a SwiftUI ScrollView as well?
0
0
101
Sep ’25
iOS 26 UIKIt: Where's the missing cornerConfiguration property of UIViewEffectView?
In WWDC25 video 284: Build a UIKit app with the new design, there is mention of a cornerConfiguration property on UIVisualEffectView. But this properly isn't documented and Xcode 26 isn't aware of any such property. I'm trying to replicate the results of that video in the section titled Custom Elements starting at the 19:15 point. There is a lot of missing details and typos in the code associated with that video. My attempts with UIGlassEffect and UIViewEffectView do not result in any capsule shapes. I just get rectangles with no rounded corners at all. As an experiment, I am trying to recreate the capsule with the layers/location buttons in the iOS 26 version of the Maps app. I put the following code in a view controller's viewDidLoad method let imgCfgLayer = UIImage.SymbolConfiguration(hierarchicalColor: .systemGray) let imgLayer = UIImage(systemName: "square.2.layers.3d.fill", withConfiguration: imgCfgLayer) var cfgLayer = UIButton.Configuration.plain() cfgLayer.image = imgLayer let btnLayer = UIButton(configuration: cfgLayer, primaryAction: UIAction(handler: { _ in print("layer") })) var cfgLoc = UIButton.Configuration.plain() let imgLoc = UIImage(systemName: "location") cfgLoc.image = imgLoc let btnLoc = UIButton(configuration: cfgLoc, primaryAction: UIAction(handler: { _ in print("location") })) let bgEffect = UIGlassEffect() bgEffect.isInteractive = true let bg = UIVisualEffectView(effect: bgEffect) bg.contentView.addSubview(btnLayer) bg.contentView.addSubview(btnLoc) view.addSubview(bg) btnLayer.translatesAutoresizingMaskIntoConstraints = false btnLoc.translatesAutoresizingMaskIntoConstraints = false bg.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ btnLayer.leadingAnchor.constraint(equalTo: bg.contentView.leadingAnchor), btnLayer.trailingAnchor.constraint(equalTo: bg.contentView.trailingAnchor), btnLayer.topAnchor.constraint(equalTo: bg.contentView.topAnchor), btnLoc.centerXAnchor.constraint(equalTo: bg.contentView.centerXAnchor), btnLoc.topAnchor.constraint(equalTo: btnLayer.bottomAnchor, constant: 15), btnLoc.bottomAnchor.constraint(equalTo: bg.contentView.bottomAnchor), bg.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor), bg.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 40), ]) The result is pretty close other than the complete lack of capsule shape. What changes would be needed to get the capsule shape? Is this even the proper approach?
12
5
694
Sep ’25
iOS 26 Beta 9 dark/light behaviour over custom UIViews in UITabBarController and CPMapTemplate
I have an app where the user can choose if the dark / light mode is enabled automatically during the night / day (dusk and dawn times are calculated according to to the date and location of the user). I also have an UITabBarController, with two tabs which have a GMSMapView (Google Map View from their SDK), and three tabs with UITableViews. I have noticed that when the automatic change of dark / light mode is performed from dark to light mode, and the user is in a tab with GMSMapView, the tabBar does not change to light model, it remains in dark mode. I perform the switch by setting the self.window.overrideUserInterfaceStyle of the UIWindow of the UIScene. All the views change to light mode, including the navigation bar, but not the tab bar. If I move between the tabs with GMSMapView, the tabBar stays in dark mode. As soon as I move to a tab which contains a UITableView, the tabBar switches to light mode. If the switch to light mode is performed while the user is in tab with the UITableViews, the tabBar switches to light mode immediately, as expected. When moving to the tabs with the GMSMapViews, the tabBar stays in light mode, also as expected. I have also noticed the same problem in CarPlay, in CPMapTemplate (with a UIViewController whose view is GMSMapView), in the buttons with are set with the property “mapButtons”, and with the panning buttons. When the switch from dark mode to light mode is performed by setting the self.window.overrideUserInterfaceStyle of the UIWindow of CarPlay scene, the mapButtons keeps the glyphs in white, and set the background of the buttons to almost white, so the glyphs are barely visible unless you put png images on them instead of SF Symbols. With the panning buttons there is not workaround, since you cannot set custom images for the panning buttons. This happens even if the panning buttons are not being displayed when the switch is performed to light mode, and you enable them later. Is this a bug? Why does this only happen with view over GMSMapView (Google Maps view for a map from their SDK)? Can you think of any viable workaround? Thank you.
3
0
312
Sep ’25
iOS 26 applying blur to UIView in navigationBar
Using a storyboard, I created a UIView containing an UIImageView and a UILabel, that I dragged into the navigation bar of one of my viewControllers. In my viewDidLoad I transform the view to move it down past the bounds of the navigation bar so its hidden initially navBarMiddleView.transform = .init(translationX: 0, y: 50) Then as the screen scrolls, I slowly move it up so it slides back into the middle of the navigationBar func scrollViewDidScroll(_ scrollView: UIScrollView) { let padding: CGFloat = 70 let adjustedOffset = (scrollView.contentOffset.y - padding) navBarMiddleView.transform = .init(translationX: 0, y: max(0, (50 - adjustedOffset))) } (The content is displayed in a collectionView cell as large content initially, and I want it to remain visible as the user scrolls down. So a mini view of the same data is moved up into the navigationBar) With iOS 26 the navigationBar is applying a blur effect to this view, even when its outside the bounds of the navigationBar, meaning the content its hovering on top of is slightly obscured. I don't know why this blur is being added, how do I remove it? I've tried the following based on recommendations from chatGPT but none have worked self.navigationController?.navigationBar.clipsToBounds = true self.navBarMiddleView.layer.allowsGroupOpacity = false self.navBarMiddleView.backgroundColor = .clear self.navBarMiddleView.isOpaque = true self.navBarMiddleView.layer.isOpaque = true I have my navigation bar setup with this appearence already: let navigationBarAppearance = UINavigationBarAppearance() navigationBarAppearance.configureWithOpaqueBackground() navigationBarAppearance.backgroundEffect = nil navigationBarAppearance.backgroundColor = UIColor.clear navigationBarAppearance.shadowColor = .clear navigationBarAppearance.titleTextAttributes = [ NSAttributedString.Key.foregroundColor: UIColor.colorNamed("Txt2"), NSAttributedString.Key.font: UIFont.custom(ofType: .bold, andSize: 20) ] UINavigationBar.appearance().standardAppearance = navigationBarAppearance UINavigationBar.appearance().compactAppearance = navigationBarAppearance UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
2
0
145
Sep ’25
[iOS 26 beta 9] App is moving to Background when user rejected the GSM cellular call.
We have an application WAVE PTT(Push to talk) and Application is in foreground state, When a user receives a cellular call and it is in the "ringing" state and application receives a VoIP APNS(video call) which is reported to CallKit. User rejects the Cellular call from CallKit UI, application Video call is also getting rejected (separate feedback - 19017978) and Here the issue is observed that an Application moved to background(OS26 beta 9). Issue is not observed in iOS 18 and older versions. Frequency : 1 out of 3. Please refer the sysdiagnose logs in below reported feedback ID. Feedback Ticket ID: 20187309 Syslogs Snippet reference: default 2025-09-10 12:30:06.991950 +0530 WAVE PTX 0x10e078100 - ApplicationStateTracker: UISceneDidEnterBackground
1
0
104
Sep ’25
UIStatusBarHidden doesn't work expectedly on iOS 26
When UIStatusBarHidden is set to YES, the navigation bar is displayed in the wrong vertical position immediately after app launch. The layout only corrects itself after the device orientation changes (e.g., rotation). Steps to Reproduce: Create a new app with a navigation controller. Set UIStatusBarHidden = YES in Info.plist. Launch the app. Expected Result: The navigation bar should appear in the correct position immediately after launch. Actual Result: The navigation bar is misaligned on first launch, and only moves to the correct position after rotating the device.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
94
Sep ’25
No large titles margin on iOS 26
I need more time to adapt to the new iOS 26 UI, so I set the "UIDesignRequiresCompatibility" attribute to "Yes." This works, but now all large titles are not aligned with the content. Below you can see an example, but I have the issue with all large titles. All good on iOS 18. Does anyone have an idea why and how can i fix it?
4
2
225
Sep ’25
[UIKit, SwiftUI] Document-based app hangs when document initialization throws exception
Steps to reproduce: Create a default document-based app for iOS using SwiftUI or UIKit with UIDocumentViewController. In the document loading method, simulate an error by throwing an exception, for example: throw CocoaError(.coderValueNotFound) Open the app on device/simulator running iOS 18 and attempt to open or create a new document. Expected behavior: An appropriate error message should be displayed to the user. Actual behavior: No error message is shown to the user The "Create Document" button becomes permanently disabled The app appears to hang or become unresponsive Environment: iOS 18, 26 beta 9 Both UIKit and SwiftUI implementations affected Has anyone encountered this issue or found a workaround? This seems like a regression in iOS 18's document handling. FB20189617, FB20189669
0
0
111
Sep ’25
How to handle sequential key events with hotkey computation in UITextField (UIKit)
Hello, I am building a UIKit application where I need to handle key events in a UITextField with the following requirements: Normal key presses (e.g. A, B, etc.) should insert characters into the text field. A hotkey combination (Ctrl+K) should trigger a custom computation that runs on a background thread, and once completed, its result (e.g. $) should be inserted into the text field. All events (normal keys and hotkeys) must appear in the exact order they were pressed by the user. For example: If the user types A, B, then Ctrl+K, the field should show AB$. If the user types A, Ctrl+K, C, the field should show A$C, even if the computation for $ takes longer. I want strict sequential processing: no later keystroke should be inserted until an earlier hotkey computation finishes. I have tried overriding pressesBegan(_:with:) in a custom UITextField subclass, and I can detect both normal keys and Ctrl+K. Questions: Is there a recommended UIKit API or pattern for handling this kind of ordered key event processing with hotkeys? Are there best practices for mixing UI updates with background computations in this context, while preserving event order? Thanks!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
82
Sep ’25
Is placeCursor(at:animated:) a public API for moving the text cursor?
Hi, I came across the following API: @MainActor func placeCursor(at position: UITextPosition!, animated: Bool) From the signature, it seems intended to move the insertion point (caret) to a given UITextPosition, with an option for animation. However, UITextView and UITextField don’t seem to expose this method as a public member — calling it gives the error: Value of type 'UITextView' has no member 'placeCursor' My questions are: Is placeCursor(at:animated:) a public, supported API that we can safely use in apps? If not, what is the Apple-recommended way to programmatically move the cursor without animation? Right now, I only know of updating selectedTextRange, which works but doesn’t involve this placeCursor method. I want to confirm if placeCursor is meant for developer use or is an internal/private API. Thanks!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
76
Sep ’25
Best practices to use low-latency feature in UIUpdateLink?
Hi everyone, I'm not an experienced developer. I'm interested in the low-latency related APIs in UIUpdateLink, but I failed to write even a minimal demo that works. UIUpdateInfo.isImmediatePresentationExpected is always false here. My understanding must be wrong. I've totally no idea so I'm asking for help here. I appreciate anyone who gives suggestions of any kind. Here's my (failed) demo about tracking touch inputs (of the 1st finger) and draw some shape at that place: import UIKit class ContentUIView: UIView { // MARK: - About UIUpdateLink and drawing required init?(coder: NSCoder) { super.init(coder: coder) initializeUpdateLink() } override init(frame: CGRect) { super.init(frame: frame) initializeUpdateLink() } private func initializeUpdateLink() { self.updateLink = UIUpdateLink(view: self) self.updateLink.addAction(to: .beforeCADisplayLinkDispatch, target: self, selector: #selector(update)) self.updateLink.wantsImmediatePresentation = true self.updateLink.isEnabled = true } @objc func update(updateLink: UIUpdateLink, updateInfo: UIUpdateInfo) { print(updateInfo.isImmediatePresentationExpected) // FIXME: Why always false? CATransaction.begin() defer { CATransaction.commit() } layer.setNeedsDisplay() layer.displayIfNeeded() } override func draw(_ rect: CGRect) { // FIXME: Any way to support opacity? guard let context = UIGraphicsGetCurrentContext() else { return } context.clear(rect) guard let lastTouch = self.lastTouch else { return } let location = lastTouch.location(in: self) let circleBounds = CGRect(x: location.x - 16, y: location.y - 16, width: 32, height: 32) context.setFillColor(.init(red: 1/2, green: 1/2, blue: 1/2, alpha: 1)) context.addLines(between: []) context.fillEllipse(in: circleBounds) } // MARK: - Touch input override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { super.touchesBegan(touches, with: event) guard lastTouch == nil else { return } lastTouch = touches.first } override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { super.touchesEnded(touches, with: event) guard let lastTouch, touches.contains(lastTouch) else { return } self.lastTouch = nil } override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { self.touchesEnded(touches, with: event) } private var lastTouch: UITouch? private var updateLink: UIUpdateLink! } #Preview { ContentUIView() } Anyway, I'm not meant to find alternative APIs and I'd be willing to know what it can't do.
1
0
100
Sep ’25
Building a bidirectional, infinitely scrolling list using ScrollView - challenges and potential solutions
I have been banging my head against this problem for a bit now. I am trying to build a bidirectional, infinitely scrolling list that implements these core requirements: Loads data up/down on the fly as the user scrolls Preserves scroll velocity as the list is updated Restores the scroll to the exact visual location after data has changed Ensures no flicker when restoring scroll position - the user cannot know the list has updated and should continue scrolling as normal Because LazyVStack does not play well with animations, I am opting to go with VStack and am implementing my own sliding window for data. This means that data can be removed as well as added, and a simple application of a height delta is not enough when restoring position. So far I have tried many things: Relying on ScrollPosition - simply does not work by itself as described (swift UI trying to keep the position stable with ID's) Relying on ScrollPosition.scrollTo - only kind of works with ID, no way to restore position with pixel perfect accuracy Intercepting the UIKit scrollView instance, using it to record and access the top row's position, mutating data and then queuing a scroll restoration using CATransaction.setCompletionBlock - this is the closest I've come, and it satisfies the top 3 requirements but sometimes I get a flicker on slightly heavier lists What I would really like, is a way of using ScrollView and granularly hooking into the lifecycle of the view after layout, and just before draw. At this point I would update the relevant scroll positions, and allow draw to continue. Is this possible? My knowledge is very limited at this point, but I believe I may be able to achieve something of the sort by swizzling layerWillDraw? Does this make sense, and is it prudent? In general, I'm very interesting in hearing what people have to say about the above, as well as this problem in general.
2
0
227
Sep ’25
Is it possible to read and write layout before render with SwiftUI?
I’m trying to keep a specific row visually stable while the data backing a ScrollView changes. Goal 1. Before updating model.items, capture the top row’s offset relative to the scroll view. 2. Mutate the observable state so SwiftUI recomputes layout — but don’t draw yet. 3. Read the new layout, compute the delta, and adjust the scroll position so the previously visible row stays put. 4. Only then draw the new frame. Reduced example @Observable final class SomeModel { var items: [SomeItem] = [/* ... */] } struct MyBox: View { @Environment(SomeModel.self) private var model var body: some View { ScrollView { VStack { ForEach(model.items, id: \.id) { item in Color.red.frame(height: randomStableHeight(for: item.id)) } } } } } // Elsewhere: let oldRow = recordOldRow() // capture the row to stabilize model.items = generateNewItems() // mutate model (invalidates layout) let newPos = capturePreviousRowNewPosition(oldRow) // read new layout? restoreScrollPosition() // adjust so oldRow stays visually fixed // draw now Is that pipeline achievable in SwiftUI? If not, what’s the supported way to keep a row visually stable while the list updates?
1
0
66
Sep ’25
Issue with UIActivityViewController Not Showing X (formerly Twitter) and Facebook Icons When Sharing Images on iOS 26 Beta
I have installed the iOS 26 Beta on my device and conducted a comprehensive functionality test of my iOS application, which I designed and developed. The application includes a feature that allows users to share images directly to X (formerly Twitter) and Facebook. During testing, I encountered an issue where the icons for X (formerly Twitter) and Facebook do not appear in the share dialog, despite both apps being installed on the device. This issue prevents users from sharing images to these platforms directly from the app. Steps to Reproduce: 1.Install iOS 26 Beta on a compatible device. 2.Ensure that both the X (formerly Twitter) and Facebook apps are installed and logged in on the device. 3.Open the iOS application and navigate to the image sharing feature. 4.Attempt to share an image using the share dialog. 5.Observe that the icons for X (formerly Twitter) and Facebook are missing from the share options. Expected Behavior: The share dialog should display icons for X (formerly Twitter) and Facebook, allowing users to share images directly to these platforms. Actual Behavior: The icons for X (formerly Twitter) and Facebook do not appear in the share dialog, preventing direct sharing to these platforms. Code Implementation: I have not implemented any code to exclude X (formerly Twitter) and Facebook from the share options. Below is the relevant code for controlling the share screen: let activityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities) let excludedTypes = [ UIActivity.ActivityType.assignToContact, UIActivity.ActivityType.print, ] activityViewController.excludedActivityTypes = excludedTypes activityViewController.completionWithItemsHandler = completion self.present(activityViewController, animated: true, completion: nil) As shown in the implementation, there is no exclusion of X (formerly Twitter) and Facebook, yet their icons do not appear in the share dialog.
6
4
534
Sep ’25