如何在 tvOS 的 UITableViewCell 中聚焦 UICollectionViewCell?

How to focus a UICollectionViewCell in UITableViewCell in tvOS?

说明:

我有一个 UITableViewCell 的列表,每个列表都有一个 UICollectionView 和 X 数量的 UICollectionViewCell(为了更清楚,请参见下图)

这背后的想法是能够实现顶部 header 和水平滚动 UICollectionView

的部分

一切都很好,除了当我尝试聚焦 UICollectionViewCells(又名:CategoryCell)时。 UITableViewCell 获得焦点并突出显示所有内容,因此无法聚焦任何 UICollectionViewCell

我尝试过的:

根据其他帖子,解决此问题的方法是停用用户交互 and/or 在 UITableViewCell:

上将选择样式设置为 none
cell.selectionStyle = UITableViewCellSelectionStyle.None

并改为在 UICollectionViewCell 上启用用户交互。

以下是讨论它的帖子:

UITableViewCell with UITextField losing the ability to select UITableView row?

How can I disable the UITableView selection highlighting?

我曾尝试实施这些解决方案但没有成功。

问题:

我错过了哪一步?修复程序在 tvOS 上不起作用吗?如何将我的 UICollectionViewCell 放在 UICollectionView 中,放在 UITableViewCell 中?

更多:

图像显示了我的 UITableViewController 及其来自我的 StoryBoard 的所有内容。

问题很可能是您的 table 视图单元格正在 returning truecanBecomeFocused。您可以通过实现 UITableViewDelegate 方法 tableView(_, canFocusRowAt:) 到 return false 或通过子类化 UITableViewCell 和 returning false 来禁用它] 来自 canBecomeFocused.

焦点引擎将尝试关注来自 canBecomeFocused 的 returns true 的最顶层视图,这就是它无法找到您的集合视图单元格的原因:它们 "hidden" 在可聚焦 table 视图单元格中。如果您禁用 table 视图单元格上的焦点,那么焦点引擎将能够找到您的集合视图单元格。

override func tableView(tableView: UITableView, canFocusRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return false
}