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
Post
Replies
Boosts
Views
Activity
If an in-app purchase is made when my app is not running, the next time the app launches Transaction.updates will emits a transaction for the purchase. That's great.
But if an in-app purchase is refunded when my app is not running, the next time the app launches Transaction.updates will NOT emits a transaction for the refund. Is that the expected behaviour?
If yes, in order to check for refunds at app launch, are we supposed to cycle trough Transaction.all and search for them?
Thank you
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
Is it possible to use a string catalog to localize a settings bundle?
Currently, to localize a Settings.bundle, we need to create a folder for each language with a single strings file inside.
For example:
Settings.bundle
en.lproj > Root.strings
fr.lproj > Root.strings
de.lproj > Root.strings
...
Any way to convert that to a string catalog?
Thank you
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
When using storyboards, string catalogs automatically grab translation comments from the "Localizer Hint" attribute of the objects in the storyboard.
The problem is that we can only specify a single comment per object. What if we need to specify a specific comment for some of the attributes of the object? For example, I often need to provide a specific comment to each segment title of segmented control objects. Currently, I'm doing that by setting the managed property of each string to "Manual" and setting the comment directly from the string catalog.
There is a better way to handle these cases?
Hi,
Just want to understand what is the current state of iOS 15 prewarming app delegate behaviour.
There is a lot of confusion (and a lack of documentation) about which app delegate methods are called during prewarming.
It's not clear if didFinishLaunchingWithOptions will be called or not during prewarming.
A lot of applications are counting on UserDefaults and Keychain access in didFinishLaunchingWithOptions, but sadly these two features seems to be unavailable during prewarming causing issues.
Some users say that this was the case before 15.4 and that from 15.4 the didFinishLaunchingWithOptions app delegate method is no more called during prewarming.
Just want to know if we can have an official statement about this.
It is safe, from iOS 15.4 onwards, to use UserDefaults and access Keychain in the didFinishLaunchingWithOptions app delegate method?
Thank you
I’m exploring the new Xcode 15 string catalog feature.
I see that for every sentence there is a “screenshots” field in the Xcode inspector (see image). How can we populate this field?
Thank you
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
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
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
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
In a Core Data store I have a binary data attribute with “Allows External Storage” set to true. Everything work as expected, i.e. the data of this attribute is saved inside the _EXTERNAL_DATA folder. For every data stored into that attribute, a file is created inside _EXTERNAL_DATA with a UUID as file name and without extension. That's expected.
For some reason the _EXTERNAL_DATA folder of a particular user was full of files with an “.interim” extension.
Somebody know what are this files? In which cases files are saved with the ".interim" extension? Do we need to do anything with these files? Can they be deleted?
Thank you
Hi!I have a model with an antity that have a property that use the "Allows External Storage" option. For some reason the framework does not handle the files inside this directory correctly when some of the files have the SAME data.Basically the issue is:- You have an entity with a binary property that use the “Allows External Storage” option.- You create some entities and for every entities you put the same data in the binary property.- After saving Core Data will create inside the _EXTERNAL_DATA folder a file for every entity data.- You delete all the entities from the store.- Core Data will delete only a single file and all the other files are left in the directory forever.So if you create for example 10 identical entities (same data) with 1MB of data for every entity, after deleting all the entities from the store your _EXTERNAL_DATA folder will still contain 9MB of orphaned data that will stay there forever. 😟This bug is present in iOS 7, iOS 8 and iOS 9 beta 5.I have made a sample project that illustrate this behavior:http://www.dale1.ch/documents/delete_external_data_sample_project.zipI have filled a bug report (18319761) the 12 September 2014 with all the informations needed to reproduce the issue but unfortunally is still Open and I didn't received any feedback from Apple.Alan
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