的 “辅助功能编程指南对于iOS” 规定:你如何实现UIAccessibility协议?
Another way is to implement the isAccessibilityElement method of the UIAccessibility protocol in the implementation of your custom subclass. The following code snippet shows how to do this:
但是当我这样做,如下面的代码:
class UITextLayerLabel : UIView, UIAccessibility {
的XCode返回我这个错误:
[...] Use of undeclared type 'UIAccessibility'
我错过了什么?具体的进口?该协议仍可用于iOS 10/XCode8吗?
如果你的类继承的UIView,您自动具有被访问,因为UIView的符合这种非正式协议UIAccessibility协议的方法。不要在你的例子中指定协议,它应该像魅力一样工作。 –