我在tvOS视图上有一个UITableView
和一个UIButton
。根据{{3}},只要焦点发生变化,就应调用shouldUpdateFocusInContext:
。
但是,如果我从按钮执行此代码:
[_tableViewController setEditing:YES animated:YES];
tvOS会生成从按钮到表格视图的焦点更改,但是在我找不到的任何控制器或视图上都不会调用shouldUpdateFocusInContext:
方法。
我的问题是有时候我想在表格视图上启用编辑,但没有设置焦点。因此,我希望调用shouldUpdateFocusInContext:
方法,以便拒绝焦点更改。
任何想法如何解决这个问题?
答案 0 :(得分:0)
如果我没记错,我在shouldUpdateFocusInContext
遇到了同样的问题,并切换到this方法:
override func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
//Where DetailTableCell is my custom UITableCell
if let cell = context.nextFocusedView as? DetailTableCell {
print("called next focused.")
}
if let previous = context.previouslyFocusedView as? DetailTableCell {
print("Called previous focused.")
}
}
告诉委托上下文指定的焦点更新 刚刚发生。