[tvOS 15.0] transportBarCustomMenuItems don't handle taps

Hello!

Im using Xcode 13 beta 2 , building on Apple TV 4K, tvOS 15.0 (physical device)

I was implementing new functionality into the tvOS app I'm working on and encountered some difficulties trying to use new .transportBarCustomMenuItems property.

I'm creating a UIMenu, debug shows that Menu has children and overlay shows my created items, but when I'm trying to click on it, nothing happens, nor menus or actions don't call handler func I'm providing and those pretty controls im adding just have no use. Help me understand if I'm doing something wrong.

He's pseudo code im using

private func createLocalizationMenuControl() -> UIMenuElement? {
    let image = UIImage(systemName: "gear")
    let menuChildren = localizations.compactMap { [weak self] localization in 
        self?.createLocaliztionAction(from: localization) 
    }

    return menu = UIMenu(title: "Localizations",
                         image: image,
                         options: [.singleSelection],
                         children: menuChildren)
}

private func createLocaliztionAction(from localization: Localiztion) -> UIAction {
    return UIAction(title: localization.name,
                    state: localization.isAvailable ? .on : .off,
                    handler: { [weak self] _ in self?.didSelectLocalization($0) })
}

Note: if I'm settings options: [.singleSelection, .displayInline] for UIMenu like it was shown in wwdc21-10191 session - its not displayed at all.

I am starting to believe its beta related. Any ideas why this could be happening or how to make it work?

Maybe anyone from Apple engineer team could help me understand how do parameters of the UIMenu reflect on its behaviour. Unfortunately there's not that much docs on this functionality yet. I would be very grateful if someone could explain this one to me.

Answered by azhukov in 686949022

Okay I managed to detect what's the problem here. Sorry for inconvenience. I have added UITapGestureRecognizer for AVPlayerViewController's view and it caught my presses when I was focused on button. But according to Responder Chain its not supposed to work that way.

I'm having focus on collectionView cell (collection of customMenuItems) and tapping one of them. I believe that my press on cell should be prioritised, but my press is handled by my custom UITapGestureRecognizer instead.

Accepted Answer

Okay I managed to detect what's the problem here. Sorry for inconvenience. I have added UITapGestureRecognizer for AVPlayerViewController's view and it caught my presses when I was focused on button. But according to Responder Chain its not supposed to work that way.

I'm having focus on collectionView cell (collection of customMenuItems) and tapping one of them. I believe that my press on cell should be prioritised, but my press is handled by my custom UITapGestureRecognizer instead.

[tvOS 15.0] transportBarCustomMenuItems don't handle taps
 
 
Q