Posts

Post not yet marked as solved
3 Replies
249 Views
Hi, I need to understand inside an override of UIBarButtonItem what is the systemItem of the button (done, add, trash, search, ...). Unfortunately at the moment the only method I found is to inspect the content of self.description (see below), but this solution, as well as being ugly, is very fragile because we can't be sure that the description will be the same also on future version of iOS / Swift. Someone know a better way to check for systemItem inside an UIBarButtonItem override class? Thank you class BarButtonItem: UIBarButtonItem {     override func awakeFromNib() {         super.awakeFromNib()         print(self.description)     } } <MyApp.BarButtonItem: 0x7fadbcacbea0> systemItem=Trash
Posted
by DaleOne.
Last updated
.
Post marked as solved
2 Replies
536 Views
Hi, I'm currently let the user pick a photo using PHPickerViewController. The advantage of PHPickerViewController is that the user is not requested to grant photo access (no permission alerts). After the user picked the photo I need to take note of the local identifier and the cloud identifier (PHCloudIdentifier). For the local identifier no problem, I just use the assetIdentifier from the PHPickerResult. For obtaining the cloud identifier (PHCloudIdentifier, on iOS 15 only) I need to use the cloudIdentifierMappings method of PHPhotoLibrary. The problem of that method is that is causing the photo library access permission alerts to display. Someone know if there is another way to get the cloud identifier from a local identifier without having to prompt the user photo library access? Thank you
Posted
by DaleOne.
Last updated
.
Post marked as solved
3 Replies
743 Views
Hi, This is how I'm currently configuring an UICollectionView sidebar cell. let rowRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, SidebarItem> { (cell, indexPath, item) in var contentConfiguration = UIListContentConfiguration.sidebarSubtitleCell() contentConfiguration.text = item.title contentConfiguration.secondaryText = item.subtitle contentConfiguration.image = item.image cell.contentConfiguration = contentConfiguration } In order to specify the selection background color of the cell I'm setting the backgroundConfiguration property. This work as expected: let rowRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, SidebarItem> { (cell, indexPath, item) in var contentConfiguration = UIListContentConfiguration.sidebarSubtitleCell() contentConfiguration.text = item.title contentConfiguration.secondaryText = item.subtitle contentConfiguration.image = item.image cell.contentConfiguration = contentConfiguration var backgroundConfiguration = UIBackgroundConfiguration.listSidebarCell() backgroundConfiguration.backgroundColorTransformer = UIConfigurationColorTransformer { [weak cell] (color) in if let state = cell?.configurationState { if state.isSelected || state.isHighlighted { return UIColor(named: "Primary")! } } return .clear } cell.backgroundConfiguration = backgroundConfiguration } Now I also need to change the text color based on the cell selection. When the cell is selected the text should be white. I tried to set the colorTransformer of textProperties of contentConfiguration like so: contentConfiguration.textProperties.colorTransformer = UIConfigurationColorTransformer { [weak cell] (color) in if let state = cell?.configurationState { if state.isSelected || state.isHighlighted { return .white } } return .black } Unfortunately the text color does not change after the cell has been selected. What am I doing wrong? Can anyone help me? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
3 Replies
747 Views
Hi, It seems that when using the inset grouped style in a UITableView, the cells are not aligned with the navigation bar large title. However, I've noticed that all Apple apps that seem to use this style (Settings, Notes) don't have this issue and the cells are perfectly aligned with the title. In the below example you can see that the cells of an inset grouped table are not aligned with the title (extra space between the red line and the cells) but the one's of the Apple apps are perfectly aligned. Do you know if there is a way to change the left and right cells margins of an inset grouped table in order to align them with the large title? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
2 Replies
921 Views
Hi! When using a diffable data source on iOS 13 and iOS 14 in combination with a fetched result controller, the didChangeContentWith method of the NSFetchedResultsController delegate return a new snapshot with inserted, deleted and moved items. Unfortunately, in the new snapshot items that have been modified are not refreshed. That's because the system appears to compare the identifiers to determine whether a refresh is needed or not. If we change an attribute of a Core Data entity the identifier remain the same and the item in the snapshot is not refreshed. For this reason, on iOS 13 and iOS 14, we need to manually check which objects have been updated and manually refresh the corresponding items in the snapshot. Now, it seems that on iOS 15 this is no more needed. The new snapshot I receive in the NSFetchedResultsController didChangeContentWith delegate method also contain refreshed items. So, in order to apply the new snapshot I only need to call a single line of code: func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { guard let diffableDataSource = diffableDataSource else {return} diffableDataSource.apply(snapshot as NSDiffableDataSourceSnapshot<Section, NSManagedObjectID>, animatingDifferences: true) } That's great, but I'm not sure if that's a feature we can count on from iOS 15 onwards. Is this new behaviour documented somewhere? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
0 Replies
426 Views
I'm developing an iOS 14 Catalyst app and I'm trying to setup the window toolbar. I created a NSToolbar and assigned to the scene window titlebar property. var toolbarDelegate = ToolbarDelegate() func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { #if targetEnvironment(macCatalyst) guard let windowScene = scene as? UIWindowScene else { return } let toolbar = NSToolbar(identifier: "main") toolbar.delegate = toolbarDelegate toolbar.displayMode = .iconOnly if let titlebar = windowScene.titlebar { titlebar.toolbar = toolbar titlebar.toolbarStyle = .unified titlebar.titleVisibility = .hidden } #endif } I then assigned some items to the toolbar via the toolbarDefaultItemIdentifiers delegate method. func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { let identifiers: [NSToolbarItem.Identifier] = [ .toggleSidebar, .print, .flexibleSpace, .print ] return identifiers } This work as expected. Now, let's say that I want to align some items with the edges of the supplementary column. I found that there is an NSToolbarItem named supplementarySidebarTrackingSeparatorItemIdentifier. This item appears to allow us to align items with the supplementary column. If I do this: func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { let identifiers: [NSToolbarItem.Identifier] = [ .toggleSidebar, .flexibleSpace, .print, .supplementarySidebarTrackingSeparatorItemIdentifier, .print, .flexibleSpace, .print ] return identifiers } I got the following result which is exactly what I want to achieve (the items are aligned with the supplementary column): But there are some issues. As you can see from the above image for some reason the background color of the toolbar on top of the supplementary column become white. But it's worse. If I resize the window the background instantly become gray: If I then scroll the content of the supplementary column the toolbar become white again. Another issue is that If I collapse the primary column the toolbar on top of the supplementary column loose the right separator line. Why? I tried to search some info online but if I try to search for supplementarySidebarTrackingSeparatorItemIdentifier I got only 5 results! One of these is Apple's official documentation page, which does not contain any info about the behaviour of this item: Apple documentation about supplementarySidebarTrackingSeparatorItemIdentifier At this point I wonder if this item is ready to be used in real apps. Someone has experience using the supplementarySidebarTrackingSeparatorItemIdentifier item? There is a way to align toolbar items with the supplementary column without having the above described issues? (different toolbar background color, missing toolbar separator line) Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
4 Replies
951 Views
If we use white as tint color for an inline or compact UIDatePicker (iOS 14, dark mode) then if the today day is selected the number become unreadable. The problem is that the today day number color is always white and, when selected, the background color is also white. Anyone know a way to set the color of today's day number to black when is selected? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
1 Replies
573 Views
I'm using the following code to get the height of the keyboard: class ViewController: UIViewController {     override func viewDidLoad() {         super.viewDidLoad()         NotificationCenter.default.addObserver(             self,             selector: #selector(keyboardHeight),             name: UIResponder.keyboardDidChangeFrameNotification,             object: nil         )     }     @objc private func keyboardHeight(notification: Notification) {         guard let keyboardRect = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else { return }         print("==> keyboardFrameEndUserInfoKey height: \(keyboardRect.size.height)")     } } This code on iPad work correctly when the keyboard is normal but it does not work when the keyboard is floating. After the user tap on a text field, the keyboard appear and the keyboardDidChangeFrameNotification notification is called. If the keyboard is floating then the first time we get a wrong height of 362. If the user then manually move somewhere the floating keyboard the notification is called again and the correct value of 308 is returned. It is a bug or I miss something? I need to be able to get the correct height the first time the keyboard appear. This is happening on iOS 13 and iOS 14. Any idea?
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
3 Replies
465 Views
Hi, Sometimes it is useful to show a movie to better explain the behaviour of something. Animated gifs would be perfect for this purpose. Unfortunately it doesn't seem possible to include animated gifs in posts. When I try to do it (using the "Add Image" feature) I always got this error message: Will the attachment of animated gifs be supported in the future? If not, what is the recommended way to include a short movie in a post? Thank you
Posted
by DaleOne.
Last updated
.
Post marked as solved
2 Replies
1.6k Views
Hi, On iOS 13 and iOS 14, if you have a navigation controller that use large titles and you push a controller that does not want a large title (navigationItem.largeTitleDisplayMode = .never) there is a smooth animation between the two navigation bar heights (from the large one to the small one). On iOS 15 the animation is missing and during the transition the pushed controller view top part is covered by the large title bar until the end of the transition. After the animation is done the height of the navigation bar suddenly becomes small. Here's the transition on iOS 14. The navigation bar height gradually changes from large to small: And here's the transition on iOS 15. The navigation bar height is not animated and remains the same until the end of the transition animation: I opened a bug report regarding this issue (FB9290717) but I want to know if someone has found a temporary fix for this. Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
5 Replies
3.7k Views
Hi!I noticed a strange behavior on MapKit when using the iOS 11 clustering feature.If you add some annotations on a map (with same clusteringIdentifier and same displayPriority) MapKit will correctly merge together annotations that are close.The problem is that if you remove all the annotations and then you add them back the map will no more merge the annotation together. It’s like the clustering feature simply stop working.I don’t really know if it is a bug or if I miss something.Someone else have noticed this?Alan
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
2 Replies
1k Views
Hi, I found a case that cause a list to never deselect the row when the back button is pressed. In the following code I modally present a list. When you select a row another list is displayed. If you select a row of the second list and you go back the row will stay selected. This is the code: struct ContentView: View { &#9;&#9;@State var modalVisible = false &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;Button(action:{ &#9;&#9;&#9;&#9;&#9;&#9;self.modalVisible.toggle() &#9;&#9;&#9;&#9;}) { &#9;&#9;&#9;&#9;&#9;&#9;Text("Open modal") &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;.sheet(isPresented: $modalVisible) { &#9;&#9;&#9;&#9;&#9;&#9;NavigationView { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;List { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink("Item", destination: List { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink("Sub Item", destination: Text("If you go back the row will stay selected.")) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;})                 }             }         }     } } Does anyone know if there is a way to force the list to deselect the row when the back button is pressed? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
4 Replies
1.8k Views
Hi!I hope someone can help me.A user told me that my app crashes when scrolling a tableView on iOS 13.1.2.I received the crash log and the error it’s just crazy.The crash log indicate that the error is at the first line inside the trailingSwipeActionsConfigurationForRowAt method.override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -&gt; UISwipeActionsConfiguration? { guard items.count &gt; indexPath.row else {return nil} //This line crash. … }The items property is defined as:private var items = [AnyObject]()The error is EXC_BREAKPOINT (SIGTRAP).How can this line of code crash? items is a non optional variable and indexPath is also a non optional struct.It's as if indexPath.row was deliberately creating an EXC_BREAKPOINT exception. It is possible?Another strange thing is that the user say that the app crash during scrolling. It seems that the method trailingSwipeActionsConfigurationForRowAt is called during scroll. That's also strange, it should not be called only when the user does a left swipe? Maybe it has something to do with some accessibility feature because in the call stack of crash report I see some system accessibility methods calls (see crash report below).Has anyone any ideas that can help me or has encountered a similar problem?Thank youException Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001de522a94 Termination Signal: Trace/BPT trap: 5 Termination Reason: Namespace SIGNAL, Code 0x5 Terminating Process: exc handler [1431] Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 libswiftUIKit.dylib 0x00000001de522a94 $s10Foundation9IndexPathV5UIKitE7sectionSivgTm + 52 1 libswiftUIKit.dylib 0x00000001de522a78 $s10Foundation9IndexPathV5UIKitE7sectionSivgTm + 24 2 MYAPP 0x000000010219ca4c specialized GroupTableViewController.tableView(_:trailingSwipeActionsConfigurationForRowAt:) + 272 (GroupTableViewController.swift:714) 3 MYAPP 0x0000000102194544 @objc GroupTableViewController.tableView(_:trailingSwipeActionsConfigurationForRowAt:) + 136 (:0) 4 UIKitCore 0x00000001ad6ae200 -[UITableView _trailingSwipeConfigurationAtIndexPath:fromRemoveButton:] + 2140 (UITableView.m:16580) 5 UIKit 0x00000001de7889f0 -[UITableViewCellAccessibility _privateAccessibilityCustomActions] + 544 (UITableViewCellAccessibility.m:3153) 6 UIAccessibility 0x00000001b49e6228 -[NSObject(AXPrivCategory) _retrieveCustomActionsForElement:] + 72 (NSObjectAccessibility.m:2973) 7 UIAccessibility 0x00000001b49e650c -[NSObject(AXPrivCategory) _accessibilityCustomActions] + 260 (NSObjectAccessibility.m:3021) 8 UIAccessibility 0x00000001b49e9978 -[NSObject(AXPrivCategory) _accessibilityCustomActionNamesAndIdentifiers] + 68 (NSObjectAccessibility.m:3683) 9 UIAccessibility 0x00000001b49f07bc -[NSObject(AXPrivCategory) _iosAccessibilityAttributeValue:] + 6580 (NSObjectAccessibility.m:6542) 10 UIAccessibility 0x00000001b49d1d9c _copyMultipleAttributeValuesCallback + 544 (UIAccessibilityRuntime.m:344) 11 AXRuntime 0x00000001b39fc834 ___AXXMIGCopyMultipleAttributeValues_block_invoke + 64 (AccessibilityPriv.m:1192) 12 AXRuntime 0x00000001b39fc3a8 _handleNonMainThreadCallback + 68 (AccessibilityPriv.m:467) 13 AXRuntime 0x00000001b39fc6b8 _AXXMIGCopyMultipleAttributeValues + 304 (AccessibilityPriv.m:1191) 14 AXRuntime 0x00000001b39f658c _XCopyMultipleAttributeValues + 396 (AccessibilityClientDefsServer.c:1354) 15 AXRuntime 0x00000001b3a0bd28 mshMIGPerform + 272 (MachServerHelper.c:447) 16 CoreFoundation 0x00000001a939d91c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60 (CFRunLoop.c:1937) 17 CoreFoundation 0x00000001a939cfe8 __CFRunLoopDoSource1 + 448 (CFRunLoop.c:2075) 18 CoreFoundation 0x00000001a9397c20 __CFRunLoopRun + 2144 (CFRunLoop.c:3098) 19 CoreFoundation 0x00000001a9397098 CFRunLoopRunSpecific + 480 (CFRunLoop.c:3192) 20 GraphicsServices 0x00000001b3501534 GSEventRunModal + 108 (GSEvent.c:2246) 21 UIKitCore 0x00000001ad4b77ac UIApplicationMain + 1940 (UIApplication.m:4753) 22 MYAPP 0x000000010209cae8 main + 68 (PlaceViewController.swift:25) 23 libdyld.dylib 0x00000001a9216f30 start + 4
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
6 Replies
1.2k Views
Hi, I'm testing one of my app on iOS 14 with Xcode 12 beta 3 (12A8169g) and I have a problem with my storyboards. Xcode give me this error for all the storyboards that contain a split view controller: An internal error occurred. Editing functionality may be limited. The log generated by the Xcode "Report a bug" button say: Exception name: NSInvalidArgumentException Exception reason: UITabBarController is unsupported as viewController for -[UISplitViewController setViewController:forColumn:] in Primary column It worked correctly on Xcode 12 beta 2. Has anyone encountered the same problem and found a way to fix it? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
Hi!I have an issue using the hidesBottomBarWhenPushed attribute on the iPhone X.If I set this attribute to true, when I push another controller on the iPhone X the toolbar is moving down during the animation. This is appening only on the iPhone X.I have made a video that show this behaviour. At the beginning you see the effect on a iPhone 8 and then on the iPhone X.http://www.dale1.ch/documents/hides-bottom-bar-when-pushed.movSomeone know a way to stop the toolbar from moving down during the animation?Thank youAlan
Posted
by DaleOne.
Last updated
.