PressesBegan not being called when typing on a text view

Apple has recently released a functionality that’s equivalent to Javascript’s keydown and keyup events. I followed this tutorial, and created a simple application, containing a single view controller with a text view (UITextView). I have overridden both pressesBegan and pressesEnd and these events are called on the iOS emulator, but not when I run it on the actual phone. The very simple code can be seen below. I have included breakpoints inside both functions, and none of them seem to be triggered when running on the device.

import UIKit  class ViewController: UIViewController {      override func viewDidLoad() {         super.viewDidLoad()     }      override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {         let key = presses.first?.key         super.pressesBegan(presses, with: event)     }          override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {         let key = presses.first?.key         super.pressesEnded(presses, with: event)     } } 

I am running macOS Catalina (version 10.15.5), with XCODE 11.6. I am emulating an iPhone 8 plus, the same as the actual physical phone I tested. The emulated and physical devices are running iOS 13.6. Finally, the project’s target OS is set to iOS 13.6.

Any suggestions?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.