Post not yet marked as solved
With a simple SwiftUI layout that presents a list of tasks that can present a detail view, there appears to be no way to configure the toolbar when running on Mac Catalyst.
Presenting in a NavigationView with columns gives the sidebar a toolbar that can be configured but the detail view will not have one and there is no way to add one. It will, instead, default to using iPad style toolbars which are inappropriate for macOS.
.windowToolbarStyle is unavailable to Catalyst apps.
Will this be addressed in macOS 13/iOS 16?
Post not yet marked as solved
Hi,
I'm having an issue with TVCollectionViewFullScreenLayout. The requirement is that a user can pick from a collection view of items which then presents a new ViewController with a UICollectionView using TVCollectionViewFullScreenLayout populated with cells derived from TVCollectionViewFullScreenCell, with the initial position set to the same item the user selected.
Calling collectionView.scrollToItemAt initially works but then it snaps back one position to the previous cell. Simply adding one to the index position leaves the user with an ugly animation as the view loads and then scrolls to the correct position.
I investigated the .centerIndexPath property but this is get only.
An example of the correct behaviour can be found in the TV app when selecting a title from a horizontal list of suggestions. The view that is presented starts with the item the user selected.
Post not yet marked as solved
Hi,
I am trying to list the contents of a directory selected by the user using the following code:
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
documentPicker.delegate = self
self.present(documentPicker, animated: true)
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let folderUrl = urls.first else {return}
let startAccessing	= folderUrl.startAccessingSecurityScopedResource()
guard startAccessing else {
print("ERROR")
return
}
defer {
if startAccessing {
folderUrl.stopAccessingSecurityScopedResource()
}
}
var error : NSError? = nil
NSFileCoordinator().coordinate(readingItemAt: folderUrl, error: &error) { (url) in
let startAccessing = url.startAccessingSecurityScopedResource()
guard startAccessing else {
print("ERROR 2")
return
}
defer {
if startAccessing {
folderUrl.stopAccessingSecurityScopedResource()
}
}
do {
let files = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: [.nameKey])
print(files)
} catch let filesError {
print(filesError)
}
}
}
This works for iCloud and for local files. It also, curiously, works on empty folders on the SMB server (though, obviously, it returns an empty array).
However, for SMB folders with contents I get the following cryptic error message.
Error Domain=NSCocoaErrorDomain Code=256 "The file “downloads” couldn’t be opened." UserInfo={NSURL=file:///private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/Gabgugfiles/downloads, NSFilePath=/private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/Gabgugfiles/downloads, NSUnderlyingError=0x28010b0c0 {Error Domain=NSPOSIXErrorDomain Code=10006 "Unknown error: 10006"}}
In addition, modifying the code slightly so the user picks an image instead works just fine too. I can load the image from the supplied URL.
I have read the documentation here - https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories and watched the WWDC 2019 presentation, What's New in File Management and Quicklook, where this was introduced but this hasn't turned up any answers.
My app is set up with Supports Document Browser. Is there something I'm doing wrong? The way this is described what I'm trying to do, get a list of files and act on each of them, is exactly what this is intended for yet it's not working.