如何在 tvOS 中使用 _whyIsThisViewNotFocusable?

How to use _whyIsThisViewNotFocusable in tvOS?

要调试焦点问题 _whyIsThisViewNotFocusable 方法在 tvOS 中可用,但在 shouldUpdateFocusInContext 中使用此命令进行调试 po [mainView _whyIsThisViewNotFocusable]po mainView _whyIsThisViewNotFocusable 它给了我错误:

error: <EXPR>:1:9: error: consecutive statements on a line must be separated by ';'
mainView _whyIsThisViewNotFocusable

那么 _whyIsThisViewNotFocusable 的正确用法是什么?

我在一些 stack-overflow 答案中看到了这个问题,但由于声誉较低,我无法对此发表评论 post/answer

可能您正在使用 swift,因此您不应在调试器中使用 obj-c。而是使用:

po mainView.performSelector(Selector("_whyIsThisViewNotFocusable")) 

Swift 5

(lldb) po yourView.perform(Selector("_whyIsThisViewNotFocusable"))

你也可以Turn on Live Focus Logging

In your Xcode project, select Edit Scheme and add -UIFocusLoggingEnabled YES to the Arguments Passed On Launch section.

检查此 readme

从iOS11开始,可以使用UIFocusDebugger