Post

Replies

Boosts

Views

Activity

Clustering stop working after removing all annotations
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
6
0
5.5k
Sep ’23
iOS 15 navigation bar transition between large title and small title
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
2
0
3k
Jul ’21
PHCloudIdentifier without photo library access prompt
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
2
0
1.4k
Jan ’22
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
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
Preprocessor, variables and "Will never be executed"
I need to set the value of a variable according to a preprocessor rule, like in the example below. var doSomething = false #if targetEnvironment(macCatalyst) doSomething = true #endif if doSomething { print("Execute!") } If I build the code for an iOS simulator, Xcode will generate a "Will never be executed" alert at the print("Execute!") line. This make sense because preprocessor rules are evaluated before compilation and therefore the code above, when the target is an iOS simulator, corresponds to: var doSomething = false if doSomething { print("Execute!") } I just want to know if there is any advices for handling cases like that. Ideally, I would like to avoid using the preprocessor condition for every statement, like so: #if targetEnvironment(macCatalyst) print("Execute!") #endif but rely on a variable like the original example. I would also prefer to avoid completely disabling in Xcode the display of "Will never be executed" warnings for all source codes. Is there a way to set the "doSomething" variable so that Xcode doesn't display the warning in a case like that? Thank you
1
0
1.1k
Mar ’22
Pending purchases in StoreKit 2
Hi, I'm looking for a way to get the list of pending purchases, i.e. the purchases made when the "Ask to buy" feature is enabled and which have yet to be approved. I need this in order to update the UI of my store and disable the possibility to buy products when they are pending for approval. I tried to look into Transaction.all but pending transactions seems to be missing. How can we get the list of pending purchases? Thank you
1
0
2.3k
May ’22
MKMarkerAnnotationView glyphImage for a cluster annotation
Hi, I want to set the glyphImage property for an annotation view (MKMarkerAnnotationView) of a cluster annotation (MKClusterAnnotation). Using the below code, inside the marker I get, instead of the glyphImage, the standard cluster number. func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { if let cluster = annotation as? MKClusterAnnotation { var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "GroupMapClusterAnnotation") if annotationView == nil { annotationView = MKMarkerAnnotationView(annotation: cluster, reuseIdentifier: "GroupMapClusterAnnotation") } (annotationView as? MKMarkerAnnotationView)?.glyphImage = UIImage(systemName: "star.fill") return annotationView } } I think that the problem is that if you keep the glyphText property empty, MapKit automatically set it with the number of the cluster member annotations. The documentation for glyphImage says: Use this property or the glyphText property to specify the marker balloon content. If you specify both an image and text, MapKit displays the text. So, MapKit is setting glyphText with a value an therefore the glyphImage property is ignored. How can we use the glyphImage property for a cluster annotation? Thank you
1
0
1.5k
Jun ’22
NSWindowDelegate windowShouldClose on Catalyst
Hi, I'm looking for a way to do something when the user presses the window red close button on a Catalyst app. For example, in some cases, I need to display an alert and prevent the window from closing. On AppKit we can use the windowShouldClose delegate method of NSWindowDelegate. Unfortnuately this is not available on Catalyst. Did someone found a way on Catalyst to prevent a window from closing? Maybe there is a way to expose the AppKit NSWindowDelegate object? Thank you
2
0
1.8k
Oct ’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.8k
Nov ’22
Loop through CoreData objects and memory issue
I have an entity named Image with a binary attribute named imageData. I need to cycle trough all Image objects and do something with the data contained inside the imageData attribute. This is the code: for image in managedObjectContext.allImages { autoreleasepool { var imageData = image.imageData } } I have a lot of objects and every imageData has something like 500KB of data for a total of 3GB of data. The problem is that each time the imageData attribute is used, the data go into memory and not released until the loop is done. This is causing the memory to grow up to 3GB crashing the app. I also tried to turn the object into a fault when I'm done with it by calling refresh(_:mergeChanges:) but nothing changes: for image in managedObjectContext.allImages { autoreleasepool { var imageData = image.imageData managedObjectContext.refresh(image, mergeChanges: false) } } How can I cycle trough all objects without filling up all the memory? Thank you
1
0
1.3k
Apr ’23
Search bar in navigation bar displayed as icon
Hi, I have a controlled contained in a split view controller primary controller with a UISearchController assigned in navigationItem.searchController. On iPhone the search bar is directly displayed in the navigation bar. This is want I want. But on iPad, the search bar is hidden and a search button is displayed in the top right of the navigation bar. In order to display the search bar the user must click on the icon to display the search bar. I want the search bar to always be visible, like on iPhone. How can I achieve that? This is the code I use to include the UISearchController: let searchController = UISearchController(searchResultsController: nil) searchController.searchResultsUpdater = self searchController.obscuresBackgroundDuringPresentation = false searchController.hidesNavigationBarDuringPresentation = false navigationItem.searchController = searchController navigationItem.hidesSearchBarWhenScrolling = false And this is the result on both devices: Thank you
1
0
2.0k
Aug ’23
String(localized:) return \' as thousands separator
Just found something weird with the String(localized:) method. Let's say that I have a "%lld apples" sentence inside a string catalog. If I call String(localized:"\(1000) apples") when on the device settings the number format is "1'234'567.89" and the device language is English, then the following string is returned: 1\'000 apples Any idea why the ' character has a backslash? It's a bug or I miss something? Thank you
1
0
821
Nov ’23
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
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