我面临的一个问题涉及使用 UINavigationController 登录页面,以便在选择项目时将详细视图控制器推送到堆栈中。
我在 UIButton 的 canBecomeFocused 覆盖中放置了一个断点,并使用这个快速的小扩展询问按钮为什么它不可聚焦。
extension UIView {
func whyNotFucusable () {
print(self.perform(Selector(("_whyIsThisViewNotFocusable"))).takeUnretainedValue())
}
}
我在尝试调试时不断收到以下错误....
ISSUE: This view may not be focusable because other views or focus guides are occluding it.
首先我查了字典,这到底是什么意思....
verb, formal, technical
- stop, close up, or obstruct (an opening, orifice, or passage).
现在的问题是什么视图阻碍了我的 UIButton???
我在可视化调试器中快速打开 UI,在我的 UIButtons 顶部有一个清晰的视图。检查视图我发现 不像 iOS,其中 nagivationBar 具有默认的系统背景颜色,tvOS 的实现具有清晰的默认颜色。我意识到我没有隐藏导航栏,作为回报,它挡住了我的按钮。
我做了以下,它解决了我所有的问题:)
navController.setNavigationBarHidden(true, animated: false)
希望对你有帮助!!!