Post

Replies

Boosts

Views

Activity

How to set initial width of NSSearchToolbarItem
The default width of NSSearchToolbarItem is way too large. I want it to be similar to the Notes app. Is there an official way to do this? Setting maxSize seems to work, until I saw all kinds of layout constraint errors in the console while customising the toolbar, so that's apparently not the way to go.
0
0
637
Jul ’20
WKWebView doesn't show custom installed fonts
Since iOS 13, apps can make use of a new Fonts entitlement, with a sub option 'Use Installed Fonts' to use custom fonts installed by special font provider apps. These apps make use of the same entitlement, but with sub option 'Install Fonts'. Examples of such apps are CreativeCloud from Adobe and MyFonts from MonoType. Using installed fonts works fine, except with WKWebView. As an example, I use the following code to load some text in a WKWebView control, and use a UIFontPickerViewController to select a font. After selecting the font, both the font of the webView control and navigation bar are being updated. This works fine with built-in system fonts. But after selecting a custom installed font, only the font of the navigation bar is being updated. This indicates that the app supports the installed custom font, but not the WKWebView control. class ViewController: UIViewController { &#9;&#9;@IBOutlet weak var webView: WKWebView! &#9;&#9;var font = "Avenir Next" &#9;&#9;let html = """ &#9;&#9;<style> &#9;&#9;body { &#9;&#9;&#9;&#9;font-family: 'FONTFAMILY'; &#9;&#9;&#9;&#9;font-size: 40pt; &#9;&#9;} &#9;&#9;</style> &#9;&#9;<body> &#9;&#9;This is a test string to demonstrate the characters of a custom installed font named “<b>FONTFAMILY</b>”. Hopefully it will not be replaced by Times New Roman or some other ugly looking font. &#9;&#9;</body> &#9;&#9;""" &#9;&#9;override func viewDidLoad() { &#9;&#9;&#9;&#9;super.viewDidLoad() &#9;&#9;&#9;&#9;loadHTML() &#9;&#9;} &#9;&#9;@IBAction func selectFont(_ sender: AnyObject) { &#9;&#9;&#9;&#9;let picker = UIFontPickerViewController() &#9;&#9;&#9;&#9;picker.delegate = self &#9;&#9;&#9;&#9;present(picker, animated: true, completion: nil) &#9;&#9;} &#9;&#9;fileprivate func loadHTML() { &#9;&#9;&#9;&#9;webView.loadHTMLString(html.replacingOccurrences(of: "FONTFAMILY", with: font), baseURL: nil) &#9;&#9;&#9;&#9;navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.font : UIFont(name: font, size: 24)!] &#9;&#9;} } extension ViewController: UIFontPickerViewControllerDelegate { &#9;&#9;func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) { &#9;&#9;&#9;&#9;if let family = viewController.selectedFontDescriptor?.object(forKey: .family) as? String&#9;&#9;&#9;{ &#9;&#9;&#9;&#9;&#9;&#9;font = family &#9;&#9;&#9;&#9;&#9;&#9;loadHTML() &#9;&#9;&#9;&#9;} &#9;&#9;} } Question: what must I do get those custom installed fonts working in WKWebView? An older technique of installing custom fonts in iOS made use of configuration profiles. This works perfectly with WKWebView, but my question is about the new iOS 13 font installation technique, as explained here: https://developer.apple.com/videos/play/wwdc2019/227/
0
1
2.7k
Aug ’20
Nested Composite Attribute values are not saved in the database
According the WWDC23 presentation “What’s new in Core Data”, “Composite attributes may be nested within each other”. However, in the current macOS and iOS beta builds, only single level composite attributes (without nested composite attributes) are persisted in the SQLite database. Is this still work in progress? See example project in FB12552092.
1
0
741
Jul ’23
Regression macOS 15 beta: NSCollectionViewDiffableDataSource does not call the 'itemProvider' when the data of a visible item changes
In one of my apps, I use NSCollectionViewDiffableDataSource in tandem with NSFetchedResultsController, which provides the necessary snapshots. This works great in macOS 14.5. However, when updating data in Core Data related to a visible item in a NSCollectionView, the NSCollectionViewDiffableDataSource no longer calls the ‘itemProvider’ closure of the diffable data source when using macOS 15 Seed 3, after applying a snapshot with animation. As a result of this, the collection view does not update visible items when the related data changes. I’m talking about this piece of code which is no longer called when it concerns a visible item: dataSource = NSCollectionViewDiffableDataSource<String, NSManagedObjectID>(collectionView: collectionView, itemProvider: { // Return an NSCollectionViewItem here }) Does anyone know a workaround or solution to get updating of visible cells working in macOS 15 Seed 3, without losing animated updates? In case an Apple engineer is reading this: Are there any related API changes that must be taken into account? Is this perhaps actually a bug of NSFetchedResultsController? I’m asking this because NSTableViewDiffableDataSource does have a very similar problem in macOS 15 beta. See also FB13943853
0
0
396
Jul ’24
Regression macOS 15 beta: NSTableViewDiffableDataSource does not call the 'cellProvider' when the data of a visible cell changes
In one of my apps, I use NSTableViewDiffableDataSource in tandem with NSFetchedResultsController, which provides the necessary snapshots. This works great in macOS 14.5. However in latest macOS 15 betas, NSTableViewDiffableDataSource does not call the 'cellProvider' completion handler anymore when the data of a visible cell changes. When data of a visible cell changes, the didChangeContentWith method of NSFetchedResultsController is called correctly, but applying the provided snapshot doesn’t result in calling the said 'cellProvider' completion handler. This looks a rollback to the early state of this API in 2020. It concerns this piece of code: dataSource = NSTableViewDiffableDataSource(tableView: tableView, cellProvider: { (tableView, tableColumn, row, item) -> NSView in // Return a cell view with data }) Does anyone know a solution or workaround to get animated updates of visible cells working in macOS 15 beta? Yes, applying the snapshot without animation works, but that’s not where NSTableViewDiffableDataSource is designed for. In case an Apple engineer reads this: Looking at the sample code associated with FB13931189, is there anything wrongly implemented that prevents calling the 'cellProvider' method for visible cells? Is this perhaps actually a bug of NSFetchedResultsController? I’m asking this because NSCollectionViewDiffableDataSource does have a very similar problem (FB13943853). PS Yes, this post looks very similar to https://developer.apple.com/forums/thread/759381#759381021, because the problem is identical except that concerns NSCollectionViewDiffableDataSource.
0
1
417
Jul ’24
SF Symbol rotate animation in NSImageView looks weird in macOS 15 beta
When using the new ‘addSymbolEffect’ effect method on NSImageView with the ‘.rotate.byLayer’ parameter with an applicable SF Symbol 6 symbol, the resulting animation is not completely as expected, to say it mildly. This is the code line I use: imageView.addSymbolEffect(.rotate.byLayer, options: .repeat(.continuous), animated: true) The correct layer rotates around the correct anchor point, but the whole image is moving up and down. The same code with the same symbol in iOS 18 beta runs perfectly. Does anyone know how to get this new rotate API correctly working in macOS 15 beta? In case an Apple engineer reads this: FB13916874 contains example projects for macOS (wobbling rotation) and iOS (perfect rotation), and a screen recording what I see in macOS 15 beta.
2
0
728
Jul ’24
SF Symbols 6 app does not export 'Can Rotate' property of a layer
The SF Symbols app 6.0 (99) does not export the ‘Can Rotate’ property of layers when exporting a symbol via File > Export Symbol. Without this, all the new fantastic edit functions in the app related to rotating in SF Symbols is completely useless. This issue with the SF Symbols 6 app can be reproduced by exporting a rotatable symbol like fan.desk, and then by importing the result as custom symbol. When inspecting ‘Group 1’ of the imported symbol, it is no longer marked as rotatable. SF Symbols app 6.0 is still in beta, but hasn't been updated since 10 June. Hopefully this bug will be solved in the release version, or earlier. Does anyone know how to manually add the missing rotation info to the exported SVG file? In case an Apple engineer reads this: FB13916635
2
2
417
Jul ’24