当执行适当的手势时,为什么在我的自定义UITextView中没有调用accessibilityDecrement()和accessibilityIncrement()?

class CustomTextView: UITextView  {

   required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      accessibilityTraits = accessibilityTraits | UIAccessibilityTraitAdjustable
   }

   override func accessibilityDecrement() {
      print("Decrement")
   }

   override func accessibilityIncrement() {
      print("Increment")
   }
}

最佳答案

尝试:

isAccessibilityElement = true

accessibilityTraits = super.accessibilityTraits | UIAccessibilityTraitAdjustable

10-08 17:25