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

UIKit Documentation

Post

Replies

Boosts

Views

Activity

UICollectionView How to make a cell size itself dynamically based on its UIHostingConfiguration?
I have made an UICollectionView in which you can double tap a cell to resize it. I'm using a CompositionalLayout, a DiffableDataSource and the new UIHostingConfiguration hosting a SwiftUI View which depends on an ObservableObject. The resizing is triggered by updating the height property of the ObservableObject. That causes the SwiftUI View to change its frame which leads to the collectionView automatically resizing the cell. The caveat is that it does so immediately without animation only jumping between the old and the new frame of the view. The ideal end-goal would be to be able to add a .animation() modifier to the SwiftUI View that then determines animation for both view and cell. Doing so now without additional setup makes the SwiftUI View animate but not the cell. Is there a way to make the cell (orange) follow the size of the view (green) dynamically? The proper way to manipulate the cell animation (as far as I known) is to override initialLayoutAttributesForAppearingItem() and finalLayoutAttributesForDisappearingItem() but since the cell just changes and doesn't appear/disappear they don't have an effect. One could also think of Auto Layout constraints to archive this but I don’t think they are usable with UIHostingConfiguration? I've also tried: subclassing UICollectionViewCell and overriding apply(_ layoutAttributes: UICollectionViewLayoutAttributes) but it only effects the orange cell-background on initial appearance. to put layout.invalidateLayout() or collectionView.layoutIfNeeded() inside UIView.animate() but it does not seem to have an effect on the size change. Any thoughts, hints, ideas are greatly appreciated ✌️ Cheers! Here is the code I used for the first gif: struct CellContentModel { var height: CGFloat? = 100 } class CellContentController: ObservableObject, Identifiable { let id = UUID() @Published var cellContentModel: CellContentModel init(cellContentModel: CellContentModel) { self.cellContentModel = cellContentModel } } class DataStore { var data: [CellContentController] var dataById: [CellContentController.ID: CellContentController] init(data: [CellContentController]) { self.data = data self.dataById = Dictionary(uniqueKeysWithValues: data.map { ($0.id, $0) } ) } static let testData = [ CellContentController(cellContentModel: CellContentModel()), CellContentController(cellContentModel: CellContentModel(height: 80)), CellContentController(cellContentModel: CellContentModel()) ] } class CollectionViewController: UIViewController { enum Section { case first } var dataStore = DataStore(data: DataStore.testData) private var layout: UICollectionViewCompositionalLayout! private var collectionView: UICollectionView! private var dataSource: UICollectionViewDiffableDataSource<Section, CellContentController.ID>! override func loadView() { createLayout() createCollectionView() createDataSource() view = collectionView } } // - MARK: Layout extension CollectionViewController { func createLayout() { let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(50)) let Item = NSCollectionLayoutItem(layoutSize: itemSize) let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.8), heightDimension: .estimated(300)) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [Item]) let section = NSCollectionLayoutSection(group: group) layout = .init(section: section) } } // - MARK: CollectionView extension CollectionViewController { func createCollectionView() { collectionView = .init(frame: .zero, collectionViewLayout: layout) let doubleTapGestureRecognizer = DoubleTapGestureRecognizer() doubleTapGestureRecognizer.doubleTapAction = { [unowned self] touch, _ in let touchLocation = touch.location(in: collectionView) guard let touchedIndexPath = collectionView.indexPathForItem(at: touchLocation) else { return } let touchedItemIdentifier = dataSource.itemIdentifier(for: touchedIndexPath)! dataStore.dataById[touchedItemIdentifier]!.cellContentModel.height = dataStore.dataById[touchedItemIdentifier]!.cellContentModel.height == 100 ? nil : 100 } collectionView.addGestureRecognizer(doubleTapGestureRecognizer) } } // - MARK: DataSource extension CollectionViewController { func createDataSource() { let cellRegistration = UICollectionView.CellRegistration<UICollectionViewCell, CellContentController.ID>() { cell, indexPath, itemIdentifier in let cellContentController = self.dataStore.dataById[itemIdentifier]! cell.contentConfiguration = UIHostingConfiguration { TextView(cellContentController: cellContentController) } .background(.orange) } dataSource = .init(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: itemIdentifier) } var initialSnapshot = NSDiffableDataSourceSnapshot<Section, CellContentController.ID>() initialSnapshot.appendSections([Section.first]) initialSnapshot.appendItems(dataStore.data.map{ $0.id }, toSection: Section.first) dataSource.applySnapshotUsingReloadData(initialSnapshot) } } class DoubleTapGestureRecognizer: UITapGestureRecognizer { var doubleTapAction: ((UITouch, UIEvent) -> Void)? override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) { if touches.first!.tapCount == 2 { doubleTapAction?(touches.first!, event) } } } struct TextView: View { @StateObject var cellContentController: CellContentController var body: some View { Text(cellContentController.cellContentModel.height?.description ?? "nil") .frame(height: cellContentController.cellContentModel.height, alignment: .top) .background(.green) } }
2
1
3.0k
Jul ’22
iOS 16 unexpected rotation behaviour
Is anyone facing any issue with rotation on iOS 16? It seems to introduce some unexpected behaviour. For example, if we're on a Master screen that supports all orientations and device is in Landscape mode, presenting/pushing another Details screen that only supports Portrait automatically brings the app to Portrait with no animations. While on iOS 15 or earlier, the app remains at Landscape and only rotates to Portrait when physical device's orientation changes. Then if we dismiss/pop back to Master screen, the app again unexpectedly rotates from Portrait to Landscape with no animations. Looks like a regression bug on iOS 16 part of some recent deprecations related to shouldAutorotate or UIDevice.setValue:forKey: as well as the introduction of setNeedsUpdateOfSupportedInterfaceOrientations.
9
10
15k
Jul ’22
iOS 16 setNavigationBarHidden func crashes
Hello, i see (on Firebase) our app's users who updated their os to ios 16.0 having crash issues. Is there anybody having same problem? Almost 1000 users crashed nearly 1500 times. Because of this func is called on Main View Controller, app is currently not being used. Also "isNavigationBarHidden" property crashes when we set it true. Anyone can help? Thanks
4
1
1.5k
Aug ’22
[UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone on iPad???
Hi, in an App I maintain we have a huge crash count at launch on the iPad. While I can't reproduce it, looking at the stack trace it seems [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone evaluates to true under some conditions on iPadOS 15. (the crash occurs in an UIViewController that is allocated only on the iPhone in one code location) Is there anything that can cause [UIDevice currentDevice] to return nil, e.g. blocking the main thread? Thanks!
2
0
950
Aug ’22
UIDocumentPickerViewController -> OneDrive/G-Drive -> NSFileCoordinator
Hey, I'm not sure I'm even in the correct ballpark - trying to allow my app to download largish videos from user's OneDrive and G-Drive to app Is it correct to use NSFileCoordinator in this way? How do I report progress as it downloads the video (is it possible?) Is it correct to dismiss the picker like this? anything else wrong (or, like is....any of it correct? :) it's sort of working with my contrived examples (I created new personal G-drive / Onedrive accounts, and copied vids up there), but...when I use a file from our corporate OneDrive, from shared folder, I get: "NSCocoaErrorDomain Code=3328 "The requested operation couldn’t be completed because the feature is not supported." Is this the NSFileProvider extension (Microsoft's) complaining? public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {     guard  let url = urls.first else {       return     }     let isSecurityScoped = url.startAccessingSecurityScopedResource()     print("(#function) - iSecurityScoped = (isSecurityScoped)")     print("(#function) - document at (url)")     let filename = String(UUID().uuidString.suffix(6)) + "_" +  url.lastPathComponent     let newURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent(filename)          let readingIntent = NSFileAccessIntent.readingIntent(with: url, options: .withoutChanges)     fileCoordinator.coordinate(with: [readingIntent], queue: queue) { error in       defer {         if isSecurityScoped {           url.stopAccessingSecurityScopedResource()         }       }       if let error = error {         print("(#function) - (error)")         return       }       let safeURL = readingIntent.url       do {         let fileData = try Data(contentsOf: safeURL)         try fileData.write(to: newURL, options: .atomic)         print("(#function) - SUCCESS - newURL = (newURL)")       } catch {         print("(#function) - NOOOOO - (error)")       }     }     controller.dismiss(animated: true)   }
1
1
608
Aug ’22
UITouch after SwiftUI Drag
I'm implementing a SwiftUI control over a UIView's drawing surface. Often you are doing both at the same time. Problem is that starting with the SwiftUI gesture will block the UIKit's UITouch(s). And yet, it works when you start with a UITouch first and then a SwiftUI gesture. Also need UITouch's force and majorRadius, which isn't available in a SwiftUI gesture (I think). Here's an example: import SwiftUI struct ContentView: View { @GestureState private var touchXY: CGPoint = .zero var body: some View { ZStack { TouchRepresentable() Rectangle() .foregroundColor(.red) .frame(width: 128, height: 128) .gesture(DragGesture(minimumDistance: 0) .updating($touchXY) { (value, touchXY, _) in touchXY = value.location}) .onChange(of: touchXY) { print(String(format:"SwiftUI(%.2g,%.2g)", $0.x,$0.y), terminator: " ") } //.allowsHitTesting(true) no difference } } } struct TouchRepresentable: UIViewRepresentable { typealias Context = UIViewRepresentableContext<TouchRepresentable> public func makeUIView(context: Context) -> TouchView { return TouchView() } public func updateUIView(_ uiView: TouchView, context: Context) {} } class TouchView: UIView, UIGestureRecognizerDelegate { func updateTouches(_ touches: Set<UITouch>, with event: UIEvent?) { for touch in touches { let location = touch.location(in: nil) print(String(format: "UIKit(%g,%g) ", round(location.x), round(location.y)), terminator: " ") } } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { updateTouches(touches, with: event) } override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { updateTouches(touches, with: event) } override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { updateTouches(touches, with: event) } override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { updateTouches(touches, with: event) } } Because this is multitouch, you need to test on a real device. Sequence A: finger 1 starts dragging outside of red square (UIKit) finger 2 simultaneously drags inside of red square (SwiftUI) ⟹ Console shows both UIKit and SwiftUI touch positions Sequence B: finger 1 starts dragging inside of red square (SwiftUI) finger 2 simultaneously drags outside of red square (UIKit) ⟹ Console shows only SwiftUI touch positions Would like to get both positions in Sequence B.
2
0
1.4k
Sep ’22
How to ignore the safe area when using keyboardLayoutGuide
I have a full screen list and want to use the new keyboardLayoutGuide constraint, but by default it uses the safe area inset. How can I disable this so my list goes all the way to the bottom of the screen when the keyboard is not shown? NSLayoutConstraint.activate([ collectionView.topAnchor.constraint(equalTo: view.topAnchor), collectionView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo:  view.trailingAnchor) ])
3
1
2.3k
Sep ’22
Removing title bar on Catalyst doesn't work on Ventura
I would like to remove the title bar of the catalyst version of my app, but it does not work on Ventura. It used to work on Monterey. I am using AppDelegate lifecycle. I am following the official documentation: https://developer.apple.com/documentation/uikit/mac_catalyst/removing_the_title_bar_in_your_mac_app_built_with_mac_catalyst The code: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } #if targetEnvironment(macCatalyst) if let titlebar = windowScene.titlebar { titlebar.titleVisibility = .hidden titlebar.toolbar = nil } #endif }
11
2
3.6k
Sep ’22
UISplitViewController on Mac Catalyst Collapse the Primary (Sidebar) View Controller by Dragging the Split macOS Style?
So experimenting with UISplitViewController on Mac Catalyst. I have a triple split. The primary view controller is a sidebar. I have the default sidebar button showing in the toolbar and that collapsed/expands the sidebar fine. But when I drag to try to collapse the split (as is typical on macOS) the sidebar doesn't collapse. It clamps to the min. size. Is there anyway to enable this? I tried passing 0 to -setMinimumPrimaryColumnWidth: but that didn't work.
3
0
643
Oct ’22
Crash when presenting UIPrintInteractionController on iOS 16
Starting iOS 16 seeing some crashes related to pdf printing in the crash reporter. It looks like the issue is not so frequent. Also, I'm unable to reproduce the crash. Looks like the app crashes when the print preview dialog is opening. According to crash reports, there are some crashes on different iOS 16 versions: 16.0.0, 16.0.2, and 16.0.3. Printing code: let printInfo = UIPrintInfo.printInfo() printInfo.jobName = "Printing Job Name" self.printViewController = UIPrintInteractionController.shared self.printViewController?.printInfo = printInfo self.printViewController?.printingItem = pdfURL self.printViewController?.present(from: barButtonItem, animated: true) { (controller, completed, error) in self.printViewController = nil } Stack trace: compare_key + 4 (CGPDFObject.c:134) bsearch + 68 (bsearch.c:70) CGPDFDictionaryGetUnresolvedObject + 68 (CGPDFDictionary.c:153) CGPDFDictionaryGetObject + 44 (CGPDFDictionary.c:172) CGPDFDictionaryGetDictionary + 44 (CGPDFDictionary.c:284) get_pages_dictionary + 68 (pdf-reader.c:410) pdf_reader_get_number_of_pages + 76 (pdf-reader.c:557) -[UIPrintPreviewPageFetcher fetchNumberOfItems] + 76 (UIPrintPreviewPageFetcher.m:115) -[UIPrintPreviewViewController collectionView:numberOfItemsInSection:] + 32 (UIPrintPreviewViewController.m:482) -[UICollectionViewData _updateItemCounts] + 220 (UICollectionViewData.mm:335) -[UICollectionViewData isIndexPathValid:validateItemCounts:] + 52 (UICollectionViewData.mm:348) -[UICollectionViewData validatedGlobalIndexForItemAtIndexPath:] + 36 (UICollectionViewData.mm:778) -[UICollectionView _cellForItemAtIndexPath:] + 108 (UICollectionView.m:7112) -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 1384 (UICollectionView.m:9357) -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] + 396 (UICollectionView.m:9104) -[UICollectionView reloadItemsAtIndexPaths:] + 52 (UICollectionView.m:9124) -[UIPrintPreviewViewController reloadVisibleItems:] + 256 (UIPrintPreviewViewController.m:568) __63-[UIPrintPreviewViewController updatePdfURL:options:completed:]_block_invoke_2 + 44 (UIPrintPreviewViewController.m:305) __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSOperation.m:1545) -[NSBlockOperation main] + 104 (NSOperation.m:1564) __NSOPERATION_IS_INVOKING_MAIN__ + 16 (NSOperation.m:2189) -[NSOperation start] + 708 (NSOperation.m:2206) There is full stack trace I got from the Organizer Thanks!
12
5
3.5k
Oct ’22
UIDocumentPickerViewController ignores directoryURL on iOS/iPadOS 16.1
I found a glitch on my app on iOS/iPadOS 16.1. The directory to open files is not saved. I filed this on Feedback Assistant but Apple says that it is a specified behavior. Isn't it a bug? // // ViewController.m // #import "ViewController.h" #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> @interface ViewController () <UIDocumentPickerDelegate> @end @implementation ViewController { NSURL *directoryURL; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls { directoryURL = [[urls firstObject] URLByDeletingLastPathComponent]; } - (IBAction)trigger:(id)sender { UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initForOpeningContentTypes:@[UTTypeData] asCopy:NO]; picker.directoryURL = directoryURL; [self presentViewController:picker animated:YES completion:nil]; } @end To reproduce the issue. Tap the button and select a file on another directory. Tap the button again. The directory should be the selected one but is the default one.
5
1
1.3k
Oct ’22
How to: Compositional layout with self-sizing rows of N columns where the height of each item is set to the tallest item in its row
Paging Steve Breen! 😄 I've seen this question asked a zillion times but I've never seen an answer. Is it possible to configure compositional layout to give you a grid of N columns (say 2 or 3) where each item in each row/group self-size their height, but the heights of those items are then set to be the height of the tallest item in their row. This is easy to do if you ignore the self-sizing requirement (just use a fixed or absolute item height), but on the surface this doesn't even appear to be possible if you require self-sizing. What I've Tried Configuring a layout where the items are set to a fractional height of 1.0 and their group is set to an estimated height (ex: 100). I was hoping compositional layout would interpret this as, "Please self-size the height of the group and make each item 100% of that height." Unfortunately, compositional layout just uses the estimate you provide for the height as the actual height and no self-sizing occurs at all. Sad panda. 🐼 Use visibleItemsInvalidationHandler to attempt to identify which items share a row and reset their heights to be the height of the tallest item in that row. Sadly, the handler doesn't really have access to the data it needs to do this, nor is it allowed to change frames, nor is it called on the first layout pass, nor does it appear to be supported at all for layouts containing estimated items. In fact, if you try to use it with layouts that support self-sizing, you'll get this error message: [UICompositionalLayout] note: the section invalidation handler cannot currently mutate visible items for layouts containing estimated items. Please file an enhancement request on UICollectionView. Wishing upon a star. Oh, and I also filed a radar asking: FB11776888 Here's a visual aid: I have a little test program as well, but unfortunately I can't upload it here. Happy to share if it would be helpful. Here are a couple snippets: #1 // This doesn't work     private func makeLayout1() -> UICollectionViewCompositionalLayout {         // Item         let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), heightDimension: .fractionalHeight(1))         let item = NSCollectionLayoutItem(layoutSize: itemSize)         // Group         let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(100))         let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, repeatingSubitem: item, count: 2)         group.interItemSpacing = .fixed(10)         // Section         let section = NSCollectionLayoutSection(group: group)         return UICollectionViewCompositionalLayout(section: section)     } #2 // This self-sizes the heights of the items, but allows the items in each row to be different heights rather than providing any way to constrain them to the height of the tallest self-sized item in each row     private func makeLayout2() -> UICollectionViewCompositionalLayout {         // Item         let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), heightDimension: .estimated(100))         let item = NSCollectionLayoutItem(layoutSize: itemSize)         // Group         let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(100))         let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, repeatingSubitem: item, count: 2)         group.interItemSpacing = .fixed(10)         // Section         let section = NSCollectionLayoutSection(group: group)         return UICollectionViewCompositionalLayout(section: section)     } Options? My guess is that compositional layout simply doesn't support layouts that require a "partial second pass" per group, where the frames of the items can be updated based on information collected during self-sizing the other items in the group (to, for example, force them all to a common height, or align them top/bottom/centered within their group). If that's the case (not supported), I would love a suggestion for where I might override the layout to provide this capability. Thank you! ❤️
4
5
3.3k
Nov ’22
UITextView select All is broken on Mac Catalyst 16
The standard Command-A keyboard shortcut in a UITextView is broken in Mac Catalyst 16/ Ventura with either TextKit 2 or TextKit 1 for long texts. In iOS 16 the selection is instant but on MacOS with Catalyst a beachball is displayed for more than 50 seconds and the app consumes gigabytes of memory. Earlier versions of Mac Catalyst work fine. To duplicate this just create a small storyBoard app with an editable UITextView and paste a long document around 1Mb then use the standard Select All Command either from the keyboard or the app menu. l I use Tale of Two Cities which is about 800k to test in my app. Is there any workaround for this?
2
1
863
Nov ’22
setTitleColor not working for UIButton plain style
If I create a Plain style UIButton using the Storyboard, calling the function setTitleColor(_ color: UIColor?, for state: UIControl.State) stop working, or works in a limited way. However, the color of the title can still be modified using its titleLabel?.tintColor property. If I turn UIButton to be Default style, then setTitleColor(_ color: UIColor?, for state: UIControl.State) works as expected. Thank you Mauro Bianchelli.
2
1
1.4k
Dec ’22
iOS 16 crash on [UIKeyboardTaskQueue promoteDeferredTaskIfIdle]
Hi, I've recently experienced a weird crash that only happening on iOS 16 device (iOS 16.xx - 16.3). Here is the stack trace 0 libobjc.A.dylib 0x00000001bc11ae5c _objc_retain_x0 (in libobjc.A.dylib) + 16 1 UIKitCore 0x00000001c5c06a5c -[UIKeyboardTaskQueue promoteDeferredTaskIfIdle] (in UIKitCore) + 72 2 UIKitCore 0x00000001c5c069e8 -[UIKeyboardTaskQueue performDeferredTaskIfIdle] (in UIKitCore) + 28 3 UIKitCore 0x00000001c54039c8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] (in UIKitCore) + 372 4 Foundation 0x00000001bd21484c ___NSThreadPerformPerform (in Foundation) + 260 5 CoreFoundation 0x00000001c2f31f30 ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (in CoreFoundation) + 24 6 CoreFoundation 0x00000001c2f3e308 ___CFRunLoopDoSource0 (in CoreFoundation) + 172 7 CoreFoundation 0x00000001c2ec222c ___CFRunLoopDoSources0 (in CoreFoundation) + 336 8 CoreFoundation 0x00000001c2ed7b88 ___CFRunLoopRun (in CoreFoundation) + 832 9 CoreFoundation 0x00000001c2edcebc _CFRunLoopRunSpecific (in CoreFoundation) + 608 10 GraphicsServices 0x00000001fcf33364 _GSEventRunModal (in GraphicsServices) + 160 11 UIKitCore 0x00000001c53d2868 -[UIApplication _run] (in UIKitCore) + 884 12 UIKitCore 0x00000001c53d24cc _UIApplicationMain (in UIKitCore) + 336 13 News 0x00000001106d5d1c main (in News) (main.m:23) 14 dyld 0x00000001e16fe95c start (in dyld) + 2524
18
7
4k
Jan ’23
Crash in [UIViewController _presentViewController:withAnimationController:completion:]
Our app has a Crash, here is the Crash report. How should I investigate this error? Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x9e48 __exceptionPreprocess 1 libobjc.A.dylib 0x178d8 objc_exception_throw 2 UIKitCore 0x326cbc -[UIViewController _presentViewController:withAnimationController:completion:] 3 UIKitCore 0x325c10 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke 4 UIKitCore 0x349598 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] 5 UIKitCore 0x2b7a48 -[_UIViewControllerTransitionContext _runAlongsideCompletions] 6 UIKitCore 0x2b6ad8 -[_UIViewControllerTransitionContext completeTransition:] 7 UIKitCore 0x2b7c38 -[UITransitionView notifyDidCompleteTransition:] 8 UIKitCore 0x2b7838 -[UITransitionView _didCompleteTransition:] 9 UIKit 0xa7e58 -[UITransitionViewAccessibility _didCompleteTransition:] 10 UIKitCore 0x103d464 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ 11 UIKitCore 0xd14ac -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] 12 UIKitCore 0xd0408 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 13 UIKitCore 0xcfb28 -[UIViewAnimationState animationDidStop:finished:] 14 UIKit 0xb0f50 -[UIViewAnimationStateAccessibility animationDidStop:finished:] 15 UIKitCore 0xcfc3c -[UIViewAnimationState animationDidStop:finished:] 16 UIKit 0xb0f50 -[UIViewAnimationStateAccessibility animationDidStop:finished:] 17 QuartzCore 0x1310c CA::Layer::run_animation_callbacks(void*) 18 libdispatch.dylib 0x3fdc _dispatch_client_callout 19 libdispatch.dylib 0x127f4 _dispatch_main_queue_drain 20 libdispatch.dylib 0x12444 _dispatch_main_queue_callback_4CF 21 CoreFoundation 0x9a6d8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 22 CoreFoundation 0x7c03c __CFRunLoopRun 23 CoreFoundation 0x80ec0 CFRunLoopRunSpecific 24 GraphicsServices 0x1368 GSEventRunModal 25 UIKitCore 0x3a186c -[UIApplication _run] 26 UIKitCore 0x3a14d0 UIApplicationMain 27 Authenticator 0x9334 main + 26 (AppDelegate.swift:26) 28 ??? 0x1b65de960 (シンボルが不足しています)
4
2
928
Jan ’23
Fatal Exception: NSInternalInconsistencyException Failed to create remote render context
Hi I am receiving this error in crashlytics and I am not sure what is going on. Based from the crashlytics report, it is only happening from iOS 16.2 and above. Any tips and hints on this problem would be great. Here is the bug report. Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation         0x9e48 __exceptionPreprocess 1 libobjc.A.dylib        0x178d8 objc_exception_throw 2 Foundation           0x545a88 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] 3 UIKitCore           0x6a2724 __UIKIT_DID_NOT_RECEIVE_A_REMOTE_CACONTEXT_FROM_COREANIMATION_INDICATING_A_POSSIBLE_BACKBOARDD_CRASH 4 UIKitCore           0x5260ec __UIKIT_IS_REQUESTING_A_CACONTEXT_FROM_COREANIMATION 5 UIKitCore           0x347ef0 +[_UIContextBinder createContextForBindable:withSubstrate:] 6 UIKitCore           0x347c64 -[_UIContextBinder _contextForBindable:] 7 UIKitCore           0x347b40 -[_UIContextBinder attachBindable:] 8 UIKitCore           0x13ab50 -[UIWindowScene _windowUpdatedVisibility:] 9 UIKitCore           0x206b80 -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] 10 UIKitCore           0x20643c -[UIWindow _setHidden:forced:] 11 UIKitCore           0x34608c -[UITextEffectsWindow _commonInitWithOptions:] 12 UIKitCore           0x345fb8 -[UITextEffectsWindow(UIObjectsForPerCanvas) _initWithCanvas:options:] 13 UIKitCore           0x206908 +[_UIObjectPerCanvas objectOfClass:forCanvas:withOptions:createIfNecessary:] 14 UIKitCore           0xf1d6c4 +[UITextEffectsWindow _sharedTextEffectsWindowforWindowScene:allowHosted:forViewService:matchesStatusBarOrientationOnAccess:shouldCreateIfNecessary:] 15 UIKitCore           0xf1d844 +[UITextEffectsWindow sharedTextEffectsWindowForWindowScene:forViewService:] 16 UIKitCore           0x8e39e4 -[UIKeyboardSceneDelegate containerWindowForViewService:] 17 UIKitCore           0x235094 -[UITextSelectionView showInitialCaret] 18 UIKitCore           0x234120 -[UITextSelectionView updateSelectionRects] 19 UIKitCore           0x233754 -[UITextSelectionView updateSelectionRectsIfNeeded] 20 UIKitCore           0x2336e4 __51-[UITextSelectionView deferredUpdateSelectionRects]_block_invoke 21 CoreFoundation         0x91d40 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 22 CoreFoundation         0x1a290 __CFRunLoopDoObservers 23 CoreFoundation         0x7bb70 __CFRunLoopRun 24 CoreFoundation         0x80ec0 CFRunLoopRunSpecific 25 GraphicsServices        0x1368 GSEventRunModal 26 UIKitCore           0x3a186c -[UIApplication _run] 27 UIKitCore           0x3a14d0 UIApplicationMain 28 MyApp           0x6274 main + 32 (AppDelegate.swift:32) 29 ???              0x1aad76960 (Missing)
3
0
1k
Jan ’23
Crash in NSDiffableDataSourceSnapshot.deleteItems
The following crash is happening in iOS 16 when we call snapshot.reconfigureItems(ids). We get the ids to reload by calling the CollectionView's indexPathsForVisibleItems, where the idea is to refresh the currently visible items. #0 (null) in __exceptionPreprocess () #1 (null) in objc_exception_throw () #2 (null) in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] () #3 (null) in -[__UIDiffableDataSourceSnapshot _validateReloadUpdateThrowingIfNeeded:] () #4 (null) in -[__UIDiffableDataSourceSnapshot _commitUpdateAtomic:] () #5 (null) in -[__UIDiffableDataSourceSnapshot reconfigureItemsWithIdentifiers:] () #6 (null) in NSDiffableDataSourceSnapshot.deleteItems(_:) () We are also seeing a slight variation of the same crash: #0 (null) in __exceptionPreprocess () #1 (null) in objc_exception_throw () #2 (null) in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] () #3 (null) in -[_UIDiffableDataSourceUpdate initWithIdentifiers:sectionIdentifiers:action:desinationIdentifier:relativePosition:destinationIsSection:] () #4 (null) in -[_UIDiffableDataSourceUpdate initWithReconfiguredItemIdentifiers:] () #5 (null) in -[__UIDiffableDataSourceSnapshot reconfigureItemsWithIdentifiers:] () #6 (null) in NSDiffableDataSourceSnapshot.deleteItems(_:) () These two crashes taken together currently account for 50% of all our app's crashes. According to the data we have, it is specific to iOS 16. Some questions: Is there anything we can do to mitigate this crash? Can we safely call snapshot.reloadItems(ids) instead? If so, how much of a performance hit would we expect to get?
1
0
727
Feb ’23
UIDeferredMenuElement With Uncached Provider Not Working on Mac Catalyst. Uncached provider block never called and menu displays as "Loading"
I'm trying to create a dynamic menu on Mac Catalyst. Using a UIBarButtonitem like so to make a "pull down" button: UIDeferredMenuElement *deferredmenuElement; deferredmenuElement = [UIDeferredMenuElement elementWithUncachedProvider:^(void (^ _Nonnull completion)(NSArray<UIMenuElement *> * _Nonnull)) { UIAction *actionOne = [UIAction actionWithTitle:@"Action One" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { NSLog(@"action one fired."); }]; UIAction *actionTwo = [UIAction actionWithTitle:@"Action Two" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { NSLog(@"action two fired."); }]; UIAction *actionThree = [UIAction actionWithTitle:@"Action Three" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) { NSLog(@"action three fired."); }]; completion(@[actionOne,actionTwo,actionThree]); }]; UIMenu *wrappedMenu = [UIMenu menuWithChildren:@[deferredmenuElement]]; UIBarButtonItem *uiBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:nil menu:wrappedMenu]; uiBarButtonItem.image = [UIImage systemImageNamed:@"rectangle.and.pencil.and.ellipsis"]; self.navigationItem.rightBarButtonItems = @[uiBarButtonItem]; The button appears in the toolbar but when I click it to expose the menu I get a menu with on element in it that says "Loading...". The the uncached provider block is never called. Running Ventura 13.2.1 and Xcode 14.2.
7
1
1.2k
Mar ’23
UITextView stuck in memory after link preview
I noticed that UITextViews get stuck in memory after a preview has been shown. I mean the preview you get when you long press a url. For this to work editable should be false and dataDetectorTypes should include .link. Include a url to the text and long press it. A preview should show. When you quit the preview and you remove the text view with removeFromSuperView() (or just close the ViewController containing the text view), it won't deinit anymore. You can check by overriding deinit or by checking if a weak reference (like IBOutlet) has become nil. I also noticed that two system ViewControllers stay in memory too, namely SFSafariViewController and SFBrowserRemoteViewController. I don't know if this is by design. Tried on iOS 16.2 and 16.3.1.
1
0
871
Mar ’23