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

UIKit Documentation

Post

Replies

Boosts

Views

Activity

UIDocumentBrowserViewController create new document used to work, but...
is now broken. (but definitely worked when I originally wrote my Document-based app) It's been a few years. DocumentBrowserViewController's delegate implements the following func. func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) { let newDocumentURL: URL? = Bundle.main.url(forResource: "blankFile", withExtension: "trtl2") // Make sure the importHandler is always called, even if the user cancels the creation request. if newDocumentURL != nil { importHandler(newDocumentURL, .copy) } else { importHandler(nil, .none) } } When I tap the + in the DocumentBrowserView, the above delegate func is called (my breakpoint gets hit and I can step through the code) newDocumentURL is getting defined successfully and importHandler(newDocumentURL, .copy) gets called, but returns the following error: Optional(Error Domain=com.apple.DocumentManager Code=2 "No location available to save “blankFile.trtl2”." UserInfo={NSLocalizedDescription=No location available to save “blankFile.trtl2”., NSLocalizedRecoverySuggestion=Enable at least one location to be able to save documents.}) This feels like something new I need to set up in the plist, but so far haven't been able to discover what it is. perhaps I need to update something in info.plist? perhaps one of: CFBundleDocumentTypes UTExportedTypeDeclarations Any guidance appreciated. thanks :-)
1
0
229
Sep ’24
A glitch with retained view controllers on Catalyst
Hello! I discovered a bug on Catalyst about a three years ago but it still seems to be not fixed. My bug report number is FB9705748. The Internet is silent on this so I'm even not sure, perhaps it's only me. So to the problem. When you display UICollectionViewController or UIViewController that contains UICollectionView, interact with the collection view then dismiss the view controller, the displayed view controller isn't released if dismissal is done through navigation bar item. The problem occurs only when the run target is My Mac (Mac Catalyst). Everything is fine when you run on iOS or via My Mac (Designed for iPad). The sample project is uploaded to GitHub. It has a video that shows this strange behavior, see the log for 'deinit' messages. I did have some workaround to fix this but it stops to work, presumable on the new macOS. Also, chances are that it's not only UICollectionView which initiates the glitch, it's just that I only encounter it with collection views.
1
0
200
Sep ’24
strange ios crash
HI i have found libsystem_kernel.dylib crash. i can't reproduce this error even this is not unrecognisable. here is stack trace Crashed: com.apple.main-thread 0 libsystem_kernel.dylib 0xaac mach_msg_trap + 8 1 libsystem_kernel.dylib 0x107c mach_msg + 72 2 CoreFoundation 0x6c88 + 368 3 CoreFoundation 0xaf90 + 1160 4 CoreFoundation 0x1e174 CFRunLoopRunSpecific + 572 5 GraphicsServices 0x1988 GSEventRunModal + 160 6 UIKitCore 0x4e5a88 + 1080 7 UIKitCore 0x27ef78 UIApplicationMain + 336 8 libTweaks.dylib 0x2a6b4 _apdecr_UIApplicationMain(int, char**, NSString*, NSString*) + 108 9 libswiftUIKit.dylib 0x27ee4 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100 10 REDDI 0x214d6c main + 4368469356 (AppDelegate.swift:4368469356) 11 ??? 0x1028a84d0 (Missing)
1
0
190
Sep ’24
I have a question regarding UI hang issues when using CompositionalLayout. As the number of cells displayed on the screen increases, the UI becomes less responsive. Could you provide advice or solutions for optimizing performance in such cases?
We are currently combining AutoLayout and StackView to structure our cells, and we’re using UICollectionViewCompositionalLayout to set up sections. Additionally, we’re utilizing UICollectionViewDiffableDataSource to manage the data source. On the home screen, we display cells in a multi-section layout. In the main screen, we support infinite scrolling and use a paging method that fetches 10 items at a time from the API. As we fetch and render more data, the number of displayed cells increases. However, we’ve noticed that as the number of displayed cells grows, the UI freezes during the process of fetching and rendering more data. We suspect that the issue lies in the configuration of UICollectionViewCompositionalLayout. When data is fetched through paging, the data is applied to the CollectionViewDiffableDataSource, and during the process of displaying it on the screen, the method that configures the UICollectionViewCompositionalLayout layout is called. The problem here is that when 10 cells are displayed on the screen and we fetch more data through paging and add 10 more cells, the layout calculation is redone for all 20 cells. In other words, the UICollectionViewCompositionalLayout layout configuration occurs a total of 20 times. Because of this, it seems that the UI freezing issue occurs as the number of cells increases. What steps can we take to resolve this problem? We have attached the relevant code for your reference. private lazy var collectionView = UICollectionView( frame: .zero, collectionViewLayout: self.createCollectionViewLayout() ) private func createCollectionViewLayout() -> UICollectionViewLayout { let layout = UICollectionViewCompositionalLayout { [weak self] sectionIndex, _ in guard let self, self.dataSource.snapshot().sectionIdentifiers.isEmpty == false else { return LayoutProvider.emptySection() } private func applyRefreshSnapshot(with sections: [PlateViewSection]) { var snapshot = self.dataSource.snapshot() snapshot.deleteAllItems() snapshot.appendSections(sections) sections.forEach { section in snapshot.appendItems(section.items, toSection: section) } self.dataSource.apply(snapshot, animatingDifferences: false) } let sectionIdentifier = self.dataSource.snapshot().sectionIdentifiers[safe: sectionIndex] let analyticsScreen = self.payload.analyticsScreen switch sectionIdentifier?.module { case let .tabOutlined(_, reactor): if self.tabOutlinedView == nil { let tabOutlinedView = self.dependency.tabOutlinedViewFactory.create( payload: .init( reactor: reactor, collectionView: self.collectionView, analyticsScreen: analyticsScreen, currentDisplayDepthObserver: .init { event in guard let depth = event.element else { return } self.currentLayoutHeaderTabDepth = depth }, selectedTabItemObserver: .init { [weak self] event in guard let (tab, isPrimaryTabClick) = event.element else { return } var queryParams: [String: String]? if isPrimaryTabClick == false { guard let currentState = self?.reactor?.currentState else { return } let currentSelectedQueryParams = self?.dependency.userDefaults .dictionary(forKey: Keys.PlateParamsKeys.brandQueryParams) as? [String: String] queryParams = currentSelectedQueryParams ?? currentState.defaultQueryParams } self?.scrollCollectionViewToTop() self?.collectionView.viewWithTag( QueryToggleModuleCell.Metric.optionsMenuViewTag )?.removeFromSuperview() self?.reactor?.action.onNext(.refreshWithParams( tabParams: tab?.params, queryParams: queryParams )) } ) ) self.view.addSubview(tabOutlinedView) tabOutlinedView.snp.makeConstraints { make in make.top.leading.trailing.equalToSuperview() } self.view.layoutIfNeeded() self.tabOutlinedView = tabOutlinedView self.tabOutlinedView?.emitInitializeAction() } return LayoutProvider.emptySection() case let .carouselOneRowBrand(module, _): let section = self.dependency.layoutProvider.createLayoutSection(module: module) section.visibleItemsInvalidationHandler = { [weak self] _, _, _ in guard let self else { return } self.emitFetchLikedAction(module: module, sectionIndex: sectionIndex) } return section case let .queryToggle(module): return self.dependency.layoutProvider.createLayoutSection(module: module) case .loadingIndicator: return LayoutProvider.loadingIndicatorSection() case let .space(module): return self.dependency.layoutProvider.createLayoutSection(module: module) case let .noResult(module): return self.dependency.layoutProvider.createLayoutSection(module: module) case let .buttonViewAll(module): return self.dependency.layoutProvider.createLayoutSection(module: module) case .footer: return LayoutProvider.footerSection() default: return LayoutProvider.emptySection() } } return layout } private func applyAppendSnapshot(with sections: [PlateViewSection]) { var snapshot = self.dataSource.snapshot() // loadingIndicator section delete let sectionsToDelete = snapshot.sectionIdentifiers.filter { section in section.module == .loadingIndicator } snapshot.deleteSections(sectionsToDelete) snapshot.appendSections(sections) sections.forEach { section in snapshot.appendItems(section.items, toSection: section) } self.dataSource.apply(snapshot, animatingDifferences: false) }
3
0
196
Sep ’24
UICardViewController does not load cells
I am making an IOS application using XCode Storyboard. I have a UICollectionViewController in the following structure UIViewController -> UIView -> UITabBarController -> UICollectionViewController The app loads without crashing, and UICollectionViewController.viewDidLoad() and .numberOfSections() execute correctly. But anything that I put in override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) does not seem to execute. Once the app loads, no cells load. And any print statement in the function doesn't execute either. All elements have their corresponding class correctly assigned in the Storyboard Identity Inspector, and the cells have the correct reusable identifier. How can I make it work correctly? My Collection View Controller: class ValidCardsCollectionViewController: UICollectionViewController { let dataSource: [String] = ["hearts", "clubs", "diamonds", "spades"] override func viewDidLoad() { super.viewDidLoad() print(dataSource) } override func numberOfSections(in collectionView: UICollectionView) -> Int { print("Loading \(dataSource.count) cells") return dataSource.count } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { var cell = UICollectionViewCell() if let cardCell = collectionView.dequeueReusableCell(withReuseIdentifier: "CardCell", for: indexPath) as? CardCollectionViewCell{ cardCell.configure(with: dataSource[indexPath.row]) cell = cardCell } print("loading cell") return cell } My UICollectionViewCell: class CardCollectionViewCell: UICollectionViewCell { @IBOutlet weak var lblStr: UILabel! func configure(with str:String){ lblStr.text = str } } Storyboard layout: Simulator:
3
0
170
Sep ’24
UIDeferredMenuElement on MacCatalyst: closure called only once on first menu display
Hi folks, I'm struggling with an issue on MacCatalyst. I'm using a dynamic menu that is supposed to show the current state of a setting (state = .on / .off). The UIDeferredMenuElement works great on iOS, the closure is called on each display of the (context) menu. On MacCatalyst however - where I use the menu as a submenu in the main menu - the closure is called only once on first menu display. The system seems to show a cached menu item even though I'm using UIDeferredMenuElement.uncached. Here's the relevant code: func getMenuElement() { let element = UIDeferredMenuElement.uncached { completion in let modeString = mode.myLocalizedDescription let trackingMode = <current setting> let mode = <menu item setting option> let state = trackingMode == mode ? .on : .off let action = UIAction(title: modeString, image: <image>, state: state) { _ in viewController.setUserTrackingMode(mode) } completion([action]) } return element } Any ideas how to trick the system into generating the dynamic menu item on each menu display?
1
0
314
Aug ’24
[UITextView becomeFirstResponder] crash with [__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]
I am trying to set my UITextView as the first responder with [self.textView becomeFirstResponder] when my view controller called viewDidAppear. But sometimes it will cause crash with the error: [__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0] all I did is just: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self.textView becomeFirstResponder]; } So if anyone can tell me what happened and how to do? when I call the [self.textView becomeFirstResponder], what will be insert into the responders list? self.textView itself? Thanks very much!
0
0
207
Sep ’24
UIPrintInteractionController.shared on Mac OS Sonoma running iPad App
After updating to Mac OS Sonoma, we have encountered compatibility issues with our iPad-designed application, specifically with the AirPrint functionality, when it is run on MacOS. The AirPrint feature stopped working properly through UIPrintInteractionController.shared. We have noticed that when we compile the application using Catalyst, the AirPrint functionality is restored and works as expected. However, this solution is not viable for us due to the restrictions associated with the frameworks we are utilizing. We are seeking alternative solutions, and any help or guidance would be highly appreciated to resolve this issue and ensure a seamless and uninterrupted user experience in our application. STEPS TO REPRODUCE Create an app for ipad with just a button and this code var str = "TEST" let printInfo = UIPrintInfo(dictionary:nil) printInfo.outputType = .general printInfo.jobName = "Report" printInfo.orientation = .portrait let printController = UIPrintInteractionController.shared printController.printInfo = printInfo printController.showsNumberOfCopies = false printController.showsPageRange = false printController.showsNumberOfCopies = false let formatter = UIMarkupTextPrintFormatter(markupText: str) formatter.contentInsets = UIEdgeInsets(top: 72, left: 72, bottom: 72, right: 72) printController.printFormatter = formatter printController.present(animated: true, completionHandler: nil) 2.Run it on a MacOS with Sonoma, there is no error on console or anything but it don't work. -If you run it with Catalyst it just works when adding the Printing permission of App Sandbox in Signing & Capabilities.
10
0
2.5k
Oct ’23
iOS App is crashing
My iOS app crashes, when kept idle in the background for sometime. Below is the detailed crash report. Incident Identifier: 90DF0404-7A1D-4AF3-8892-19AB744DF0FD Distributor ID: com.apple.AppStore Hardware Model: iPhone13,3 Process: Runner [35073] Path: /private/var/containers/Bundle/Application/894B2440-D20C-4C01-B278-A0DC4B199530/Runner.app/Runner Identifier: com.era.tk Version: 5.0.2 (5) AppStoreTools: 15F31e AppVariant: 1:iPhone13,3:15 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.era.tk [793] Date/Time: 2024-09-25 13:17:31.3101 +0100 Launch Time: 2024-09-25 12:29:23.1866 +0100 OS Version: iPhone OS 17.6.1 (21G93) Release Type: User Baseband Version: 4.70.01 Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x0000000100c75e48 Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [35073] Triggered by Thread: 0 Thread 0 Crashed: 0 Runner 0x0000000100c75e48 0x100c2c000 + 302664 1 Runner 0x0000000100c75e80 0x100c2c000 + 302720 2 UIKitCore 0x00000001a7e937e8 -[UIViewController _setViewAppearState:isAnimating:] + 1224 (UIViewController.m:6441) 3 UIKitCore 0x00000001a80520b0 -[UIViewController __viewWillDisappear:] + 108 (UIViewController.m:6705) 4 UIKitCore 0x00000001a8602cec -[UINavigationController _startCustomTransition:] + 1476 (UINavigationController.m:2260) 5 UIKitCore 0x00000001a7e97400 -[UINavigationController _startDeferredTransitionIfNeeded:] + 496 (UINavigationController.m:8062) 6 UIKitCore 0x00000001a7efc248 -[UINavigationController __viewWillLayoutSubviews] + 96 (UINavigationController.m:8369) 7 UIKitCore 0x00000001a81be688 -[UILayoutContainerView layoutSubviews] + 172 (UILayoutContainerView.m:89) 8 UIKitCore 0x00000001a7da7918 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528 (UIView.m:20054) 9 QuartzCore 0x00000001a720626c CA::Layer::layout_if_needed(CA::Transaction*) + 504 (CALayer.mm:10816) 10 QuartzCore 0x00000001a7205df0 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148 (CALayer.mm:2598) 11 QuartzCore 0x00000001a7260fd8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 (CAContextInternal.mm:2760) 12 QuartzCore 0x00000001a71d5ee0 CA::Transaction::commit() + 648 (CATransactionInternal.mm:432) 13 QuartzCore 0x00000001a721fc34 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:942) 14 UIKitCore 0x00000001a7e50ee8 _UIApplicationFlushCATransaction + 52 (UIApplication.m:3181) 15 UIKitCore 0x00000001a7e4e660 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:119) 16 UIKitCore 0x00000001a7e4e2a4 schedulerStepScheduledMainSection + 172 (_UIUpdateScheduler.m:1058) 17 UIKitCore 0x00000001a7e4f148 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1221) 18 CoreFoundation 0x00000001a5b6b834 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 (CFRunLoop.c:1957) 19 CoreFoundation 0x00000001a5b6b7c8 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001) 20 CoreFoundation 0x00000001a5b69298 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038) 21 CoreFoundation 0x00000001a5b68484 __CFRunLoopRun + 828 (CFRunLoop.c:2955) 22 CoreFoundation 0x00000001a5b67cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420) 23 GraphicsServices 0x00000001ea5b51a8 GSEventRunModal + 164 (GSEvent.c:2196) 24 UIKitCore 0x00000001a81a1ae8 -[UIApplication _run] + 888 (UIApplication.m:3713) 25 UIKitCore 0x00000001a8255d98 UIApplicationMain + 340 (UIApplication.m:5303) 26 Runner 0x0000000100c4e660 0x100c2c000 + 140896 27 dyld 0x00000001c933f154 start + 2356 (dyldMain.cpp:1298)
1
0
179
Sep ’24
Drag&Drop broken in iOS18.0?
Hi, I've encountered the following phenomenon when comparing drag&drop in iOS 18.0 with iOS 17.5: Let's say you have a small child view sitting on top of a larger parent view. In iOS 18.0, when hovering over the child view with a drag object and leaving the child view, the child view will propagate a "dropInteraction:sessionDidExit:" call to the UIDropInteractionDelegate of its parent view. The parent view now thinks, that the drag object is moved away from it (which is not the case!) and in turn its delegate doesn't receive any "dropInteraction:performDrop:" calls anymore. In iOS 17.5 this case is handled correctly (without "dropInteraction:sessionDidExit:" being propagated wrongly by child views to their parent views). Is this change in behavior intended or is this a bug?
1
0
212
Sep ’24
UISwitch initialization failure in SPM test for visionOS 2 & Xcode 16
In SPM package test running on visionOS 2, when creating a UISwitch we get a crash / error: Nil UISwitch visual element provided by <UISwitch: 0x102b15590; frame = (0 0; 0 0); layer = <CALayer: 0x6000004c1780>> (NSInternalInconsistencyException) This issue only occurs on visionOS 2 in Xcode 16 with Swift Package Manager. It works fine when running on visionOS 1.2 in Xcode 16 with SPM, as well as on iOS 18 in Xcode 16 with SPM. Additionally, running the test on visionOS inside of a non-SPM package (Project test) is also fine. What results you expected - The test should pass for UISwitch initialization on SPM for visionOS 2 on Xcode 16. What results you actually saw - Test failure with error - Nil UISwitch visual element provided by <UISwitch: 0x102b15590; frame = (0 0; 0 0); layer = <CALayer: 0x6000004c1780>> (NSInternalInconsistencyException) The version of Xcode you are using - Xcode 16 Feedback id - FB15254532
0
0
206
Sep ’24
UITabBarController didSelect item not working on iOS 18
I have been using the following function in my UITabBarController for several years, which runs some code when the user clicks a tab. I have now built the app using Xcode 16 and when I run it on my iPad with iPadOS 18, the function is not called. When I run the same app on iPadOS 16, it works just fine like it always has. Is this a bug, or is there something new that I need to do for iOS 18 support? override func tabBar(_tabBar: UITabBar, didSelect item: UITabBarItem) { // Some code } NOTE: My UITabBarController is presented from my root view controller, which is a UINavigationController.
2
1
411
Sep ’24
[iOS 18] UITabBarController disable new switching animation
Hello ! Since iOS/iPadOS 18 there is a new switch transition between tabs in UITabBarController where is a little zoom of the selected UIViewController. At first, I thought that was a bug but I found the same animation on the Apple's apps (like music, shortcuts...) On my app, this animation produce a little flash/blink white before zooming, it's not smooth like on Apple's apps. I searched on documentation but I didn't found any topics about how to disable it or handled it better. Is this possible to disabled it ?
6
3
2.2k
Sep ’24
How to transition & resize a view from one view controller to another using UIKit & Snapshots?
I am trying to seamlessly transition a view from one view controller and have it "jump" into a sheet. Apple does this in their widget picker for example when you add one of the top widgets. Based on all the documentation I've read, the most common approach to this is to snapshot the area/view that you are trying to seamlessly transition in the presented view controller (the place where the item is coming from. And then have that snapshot translate across into where it should be in the layout of the presenting view controller. func makeAnimatorIfNeeded( using transitionContext: UIViewControllerContextTransitioning ) -> UIViewPropertyAnimator { if let animator = animator { return animator } // Presentation animation let animator = UIViewPropertyAnimator( duration: 0.5, timingParameters: UISpringTimingParameters(dampingRatio: 1.0) ) guard let fromVC = transitionContext.viewController(forKey: .from), let toVC = transitionContext.viewController(forKey: .to) else { transitionContext.completeTransition(false) return animator } /// !IMPORTANT: For some weird reason, accessing the views of the view controller /// directly, like `fromVC.view` or `toVC.view` will break the sheet transition and gestures. /// Instead, use the `view(forKey:)` method of the `transitionContext` to get the views. let fromView = transitionContext.view(forKey: .from) let toView = transitionContext.view(forKey: .to) let containerView = transitionContext.containerView let fromFrame = transitionContext.viewController(forKey: .from).map { transitionContext.finalFrame(for: $0) } ?? containerView.bounds let toFrame = transitionContext.viewController(forKey: .to).map { transitionContext.finalFrame(for: $0) } ?? containerView.bounds // Calculate the frame of sourceView relative to fromVC.view to capture the correct snapshot area. let snapshotFrameInFromVC = sourceView?.convert(sourceView?.frame ?? .zero, to: fromVC.view) ?? containerView.frame // Calculate the frame of sourceView relative to containerView to position the snapshot correctly. let snapshotFrameInContainer = sourceView?.convert(sourceView?.frame ?? .zero, to: containerView) ?? containerView.frame let snapshot: UIView? if isPresenting { // Create a snapshot of fromVC.view from the defined area (snapshotFrameInFromVC). let originalColor = fromVC.view.backgroundColor fromVC.view.backgroundColor = .clear snapshot = fromVC.view.resizableSnapshotView(from: snapshotFrameInFromVC, afterScreenUpdates: true, withCapInsets: .zero) fromVC.view.backgroundColor = originalColor // Position the snapshot correctly within the snapshot container snapshot?.frame = snapshotFrameInContainer toView?.frame = toFrame toView?.transform = CGAffineTransform(translationX: 0, y: containerView.frame.size.height) toView?.layoutIfNeeded() if let fromView { containerView.addSubview(fromView) } if let toView { containerView.addSubview(toView) containerView.addSubview(snapshot ?? UIView()) } let toViewCenter = CGPoint( x: toVC.view.bounds.midX, y: toVC.view.bounds.midY + 55 ) let gestureVelocity = CGPoint(x: 0, y: -5000) animator.addAnimations { Wave.animate( withSpring: self.animatedSpring, mode: .animated, gestureVelocity: gestureVelocity ) { snapshot?.animator.frame.size = CGSize(width: 204, height: 204) // Important to animate first snapshot?.animator.center = toViewCenter } completion: { finished, retargeted in print("finished: \(finished), retargeted: \(retargeted)") } toView?.transform = CGAffineTransform.identity } animator.addCompletion { animatingPosition in switch animatingPosition { case .end: snapshot?.removeFromSuperview() transitionContext.completeTransition(true) default: transitionContext.completeTransition(false) } } } else { // Transitioning view is fromView if let toView { containerView.addSubview(toView) } if let fromView { containerView.addSubview(fromView) } animator.addAnimations { fromView?.transform = CGAffineTransform(translationX: 0, y: containerView.frame.size.height) } animator.addCompletion { animatingPosition in switch animatingPosition { case .end: transitionContext.completeTransition(true) default: transitionContext.completeTransition(false) } } } self.animator = animator return animator } I can pull this off seamlessly if the animation involves a simple movement from A to B. But if I try to resize the snapshot as well, the snapshot becomes pixelated and low quality (I assume this is because the snapshot is literally a small screenshot and I'm stretching it from 56x56 to 204x204). Is there another way that I'm overlooking to pull this off without a snapshot? Or is there a way I can resize the snapshot without losing quality? Here is the animator code, it works great without the sizing so this should help future people looking to replicate the same effect anyways.
0
0
171
Sep ’24
Tapping a TextKit 2 backed UITextView moves the caret to a random location
With the upcoming launch of Apple Intelligence and Writing Tools, we've been forced to migrate our text editing app to TextKit 2. As soon as we released the update, we immediately got complaints about incorrect selection behaviour, where the user would tap a word to begin editing, but the caret would be shown in an undefined location, often dozens of paragraphs below the selected content. To reproduce: Create a UITextView backed by a standard TextKit 2 stack and a large amount of text (50,000+ words) - see sample project below Scroll quickly through the text view (at least 20% of the way down) Tap once to select a position in the document. Expected: The caret appears at the location the user tapped, and UITextView.selectedRange is the range of the text at the location of the tap. This is the behaviour of TextKit 1 based UITextViews. Actual: The caret is positioned at an undefined location (often completely off screen), and the selectedRange is different to the range at the location of the tap, often by several thousand. There is no pattern to the magnitude of the discrepancy. This incorrect behaviour occurs consistently in the sample project on the simulator, but you may need to hide the keyboard by pulling down, then repeat steps 2-3 a few times. This happens on iPhone and iPad, and on iOS 17, 18, and 18.1. Do you have any insight into why this might be happening or how to work around this issue? Sample code is here: https://github.com/nathantesler/textkit2-issue/tree/master
2
0
325
Sep ’24
Scene Delegate Migration Lifecycle
We are in the process of migrating our application to SceneDelegate. We currently check in a variety of places if the app is running in the background for analytics reasons. The app may be running in the background due to location updates, notifications being received, or background refresh. With scene delegate, the app starts in the background state and only becomes active once a scene has connected. We have been unable to find a way if an app is truly running in the background or if a scene delegate is about to be launched.
2
0
212
Sep ’24
iOS 18.0 (22A3354) -[UIGestureRecognizer _delayTouchesForEvent:inPhase:] + 292 Crash
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Reason: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process:XXXX [XXXX] Triggered by Thread: 0 Application Specific Information: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil UserInfo:(null)' Last Exception Backtrace: 0 CoreFoundation 0x1930d108c __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x1903d32e4 objc_exception_throw + 88 (objc-exception.mm:356) 2 CoreFoundation 0x193070424 -[__NSArrayM insertObject:atIndex:] + 1276 (NSArrayM.m:164) 3 UIKitCore 0x195b6249c 0x195818000 + 3450012 4 UIKitCore 0x1958c9070 0x195818000 + 725104 5 UIKitCore 0x195899c3c _UIGestureEnvironmentUpdate + 2488 (UIGestureEnvironment.m:192) 6 UIKitCore 0x19598f914 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 336 (UIGestureEnvironment.m:843) 7 UIKitCore 0x195b2ff18 -[UIGestureEnvironment _updateForEvent:window:] + 188 (UIGestureEnvironment.m:810) 8 UIKitCore 0x195b2f2fc -[UIWindow sendEvent:] + 2948 (UIWindow.m:3627) 11 UIKitCore 0x1959c39b4 -[UIApplication sendEvent:] + 376 (UIApplication.m:12948) 13 UIKitCore 0x1959c3ee0 __dispatchPreprocessedEventFromEventQueue + 1048 (UIEventDispatcher.m:2641) 14 UIKitCore 0x1959cdcc4 __processEventQueue + 5696 (UIEventDispatcher.m:2999) 15 UIKitCore 0x1958c6270 updateCycleEntry + 160 (UIEventDispatcher.m:133) 16 UIKitCore 0x1958c3fe8 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:136) 17 UIKitCore 0x1958c3c38 schedulerStepScheduledMainSection + 172 (_UIUpdateScheduler.m:1171) 18 UIKitCore 0x1958c4bac runloopSourceCallback + 92 (_UIUpdateScheduler.m:1334) 19 CoreFoundation 0x1930a4088 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 (CFRunLoop.c:1950) 20 CoreFoundation 0x1930a401c __CFRunLoopDoSource0 + 176 (CFRunLoop.c:1994) 21 CoreFoundation 0x1930a1b08 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2031) 22 CoreFoundation 0x1930a0d04 __CFRunLoopRun + 840 (CFRunLoop.c:2949) 23 CoreFoundation 0x1930a05b8 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3414) 24 GraphicsServices 0x1deb361c4 GSEventRunModal + 164 (GSEvent.c:2196) 25 UIKitCore 0x195bf65f0 -[UIApplication _run] + 816 (UIApplication.m:3820) 26 UIKitCore 0x195ca510c UIApplicationMain + 340 (UIApplication.m:5472) 27 XXXX 0x104744880 main + 200 (main.m:41) 28 dyld 0x1b8873d34 start + 2724 (dyldMain.cpp:1334)
1
0
260
Sep ’24
UIApplication.shared.open iOS 18
Making the call as: UIApplication.shared.open(websiteURL) doesn't open the browser and gives the following in the console: BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate to the non-deprecated UIApplication.open(:options:completionHandler:). Force returning false (NO). However, making the call as: UIApplication.shared.open(websiteURL) { _ in } opens the browser and there is nothing in the cosole. Does someone understand why is this or if it's Apple's iOS 18 bug? In the iOS & iPadOS 18 RC Release Notes | Apple Developer Documentation there is a section around resolving this or something similar, unsure.
9
5
4.8k
Sep ’24