Post

Replies

Boosts

Views

Activity

UIListContentConfiguration text color during selection
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
3
0
3.3k
Jan ’22
Check for systemItem inside an UIBarButtonItem override
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
3
0
1.2k
Feb ’22
Popover from NSToolbarItem in Mac Catalyst app
Hi, Inside a Mac Catalyst app, I need to display a popover starting from an NSToolbarItem contained inside the app toolbar (like the Apple Maps Mac app does, see below image). In order to do that, when I press the button I need to find the toolbar item view and use it as popover anchor. How can I find the view or frame of an NSToolbarItem on Mac Catalyst? A property that could help me is the NSToolbarItem "view" property (NSView), but that property has been marked has unavailable in Mac Catalyst. Any idea? Thank you
3
3
1.9k
Feb ’24
Diffable data source with fetched result controller on iOS 15
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
4
0
2.8k
Oct ’21
Inset grouped table cells not aligned with large title
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
4
0
3.9k
Jan ’22
UITextView BIU button missing on iOS 16 (text formatting)
Hi, I have a UITextView with allowsEditingTextAttributes set to true. On iOS 15 and before, users can select part of the text and tap on the BIU button in order to set the text to bold, italic or underline. On iOS 16 the BIU button is missing. How can the user change the formatting of the text contained inside an UITextView on iOS 16? There is something I need to specify on UITextView? Thank you
4
0
2.9k
Nov ’22
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
287
Sep ’25
Input focus issue inside iframe
Hi!I currently developing a mobile website and found that Safari on iOS has some problems setting the focus on inputs when they are inside an iframe.When in a page you have many inputs you can tap on a field and then use the next / previous buttons on the keyboard to navigate between the fields. When the focus move to another input Safari scroll automatically the page centering the field in the page. This is great and works well.The problem is when the fields are inside a page of an iframe. In this case when you change focus from one field to another Safari has some kind of issue; the page “bounce” and the focused field is not centered in the page.I have made a video of a simple page that has this issue. In the first part of the video the page without the iframe is loaded and the focus works correctly. In the second part the page with the iframe is loaded and the issue is visible.http://www.dale1.ch/documents/safari_iframe_focus_issue.movThe code of the first page (testinput.html) where the focus is correctly handled is this:&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test input&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt;&lt;span&gt;Input 1: &lt;/span&gt;&lt;input type="text" tabindex="1" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 2: &lt;/span&gt;&lt;input type="text" tabindex="2" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 3: &lt;/span&gt;&lt;input type="text" tabindex="3" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 4: &lt;/span&gt;&lt;input type="text" tabindex="4" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 5: &lt;/span&gt;&lt;input type="text" tabindex="5" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 6: &lt;/span&gt;&lt;input type="text" tabindex="6" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 7: &lt;/span&gt;&lt;input type="text" tabindex="7" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 8: &lt;/span&gt;&lt;input type="text" tabindex="8" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 9: &lt;/span&gt;&lt;input type="text" tabindex="9" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 10: &lt;/span&gt;&lt;input type="text" tabindex="10" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 11: &lt;/span&gt;&lt;input type="text" tabindex="11" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 12: &lt;/span&gt;&lt;input type="text" tabindex="12" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 13: &lt;/span&gt;&lt;input type="text" tabindex="13" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 14: &lt;/span&gt;&lt;input type="text" tabindex="14" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 15: &lt;/span&gt;&lt;input type="text" tabindex="15" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 16: &lt;/span&gt;&lt;input type="text" tabindex="16" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 17: &lt;/span&gt;&lt;input type="text" tabindex="17" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 18: &lt;/span&gt;&lt;input type="text" tabindex="18" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 19: &lt;/span&gt;&lt;input type="text" tabindex="19" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 20: &lt;/span&gt;&lt;input type="text" tabindex="20" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 21: &lt;/span&gt;&lt;input type="text" tabindex="21" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 22: &lt;/span&gt;&lt;input type="text" tabindex="22" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 23: &lt;/span&gt;&lt;input type="text" tabindex="23" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 24: &lt;/span&gt;&lt;input type="text" tabindex="24" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 25: &lt;/span&gt;&lt;input type="text" tabindex="25" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 26: &lt;/span&gt;&lt;input type="text" tabindex="26" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 27: &lt;/span&gt;&lt;input type="text" tabindex="27" /&gt;&lt;/div&gt; &lt;div&gt;&lt;span&gt;Input 28: &lt;/span&gt;&lt;input type="text" tabindex="28" /&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;This is the code of the page that has the issue (testinput_iframe.html):&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test input&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /&gt; &lt;/head&gt; &lt;body&gt; &lt;iframe src="/testinput.html" /&gt; &lt;/body&gt; &lt;/html&gt;The issue is present in Safari on the iPhone, iPad and the xCode Simulator from version 8.4 to version 9.2.Someone know if this is a bug? There is way to fix it in css or javascript?Thanks and sorry for my english! 😉
9
0
22k
Jun ’22
Inline or compact UIDatePicker with white tint color
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
6
0
3.1k
Aug ’21
MapKit crash on Catalyst after resizing the window
Hi, I am faced with a strange problem with a Catalyst app that uses MapKit. If the map is visible and I resize the window (causing the map the resize), sometime the app crashes with some Metal related error. Is this a know issue between MapKit and Catalyst? There is something I can do in order to prevent this crash? Below you can find the error message and a screenshot of the thread that caused the crash. Thank you -[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2951: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x7f96de27f600 (label: <no label set>): <MTLToolsObject: 0x7f96dde552e0> -> <BronzeMtlTexture: 0x7f96dc04c230> label = <none> textureType = MTLTextureType2D pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB width = 2372 height = 1668 depth = 1 arrayLength = 1 mipmapLevelCount = 1 sampleCount = 1 cpuCacheMode = MTLCPUCacheModeDefaultCache storageMode = MTLStorageModeManaged hazardTrackingMode = MTLHazardTrackingModeTracked resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeManaged MTLResourceHazardTrackingModeTracked usage = MTLTextureUsageShaderRead MTLTextureUsageRenderTarget shareable = 0 framebufferOnly = 0 purgeableState = MTLPurgeableStateNonVolatile swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] isCompressed = 0 parentTexture = <null> parentRelativeLevel = 0 parentRelativeSlice = 0 buffer = <null> bufferOffset = 0 bufferBytesPerRow = 0 iosurface = 0x0 iosurfacePlane = 0 allowGPUOptimizedContents = YES'
6
2
4.6k
Nov ’22
UITabBarController is unsupported as viewController
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
7
0
2.9k
Jul ’23