Post

Replies

Boosts

Views

Activity

TVCollectionViewFullScreenLayout
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.
3
0
1.6k
Oct ’20
FileManager.default.contentsOfDirectory fails with SMB
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.
10
0
2.8k
Nov ’20
No way to configure a modern Mac-style unified toolbar in Catalyst?
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?
0
0
614
Jun ’22
Mac Catalyst Deployment Targets Not Working Properly?
Hi, I'm trying to update an app to support the new customisable toolbars in iOS 16/macOS 13. To do this, I have updated the minimum deployment target for my app appropriately for both the project and the target. When attempting to use any of the new properties of UINavigationItem (such as .style or .customizationIdentifier) the project will not compile for Mac Catalyst. These properties are listed in the documentation as supported by Mac Catalyst 16.0. An easy was to reproduce this problem: Create a new project in Xcode for iOS with Storyboards/UIKit. In the basic ViewController class that's created for you, edit viewDidLoad() and add self.navigationItem.style = .browser Build the app. It should build. Add Mac (Mac Catalyst) to the Supported Destinations and select My Mac as the current destination and build it. It will not compile as UINavigationItem has no member named style. I can find no way to specify that the Mac Catalyst version of the build should be targeting Mac Catalyst 16.0. I am using Xcode 14.0.1 with macOS Ventura 13.0.
1
1
1.3k
Oct ’22
wwdc2023-10162 - Grid Navigation on macOS
In the video 'The SwiftUI cookbook for focus" a key detail is left out. https://developer.apple.com/videos/play/wwdc2023/10162/?time=1130 selectRecipe has no code provided meaning it leaves out a vital detail, how to handle up and down keyboard presses. If a LazyVGrid has 4 items per row with the current shape of the window and the user presses the down key, how is the application supposed to know which item is directly underneath the currently focused one? Or if they press up and they need to know which is directly above? What happens when the user resizes the window and the number of items per row changes? This would seem to require knowing the exact current layout of the window to return the correct recipe ID. The code provided isn't wrapped in a complex GeometryReader so I assume there's some magic I am missing here. I am trying to create a similar LazyVGrid that can be navigated with the keyboard as with the recipes grid here but have no means of implementing .onMoveCommand in such a way that makes sense. At the moment, SwiftUI seems to be intentionally built in such a way to defy all attempts to implement keyboard navigation.
0
1
534
Oct ’23
Implementing Enhanced Dialogue on tvOS 18
How does a third party developer go about supporting the new Enhanced Dialogue option for video apps in tvOS 18? If an app is using the standard AVPlayerViewController, I had assumed it would be a simple-ish matter of building against the tvOS 18 SDK but apparently not, the options don't appear, not even greyed out.
0
0
298
Sep ’24