I created a new iOS app with a keyboard extension. I added a UITextView to it, but when I tap on it, it crashes somewhere in outside of my code. This is pretty much the keyboard extension template with the UITextView added:
(In KeyboardViewController):
super.viewDidLoad()
// Perform custom UI setup here
self.nextKeyboardButton = UIButton(type: .system)
self.nextKeyboardButton.setTitle(NSLocalizedString("Next Keyboard", comment: "Title for 'Next Keyboard' button"), for: [])
self.nextKeyboardButton.sizeToFit()
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = false
self.nextKeyboardButton.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
self.view.addSubview(self.nextKeyboardButton)
self.nextKeyboardButton.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
self.nextKeyboardButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
self.textView = UITextView(frame: .zero)
guard let textView = self.textView else { return }
textView.attributedText = NSAttributedString(string: "test keyboard")
textView.translatesAutoresizingMaskIntoConstraints = false
textView.layer.borderColor = UIColor.blue.cgColor
textView.layer.borderWidth = 2
view.addSubview(textView)
NSLayoutConstraint.activate([
textView.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
textView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 10),
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 10),
])
}
What’s interesting is that in my actual app, the same code works as long as Full Access is granted for the keyboard.
From what I understand, UITextViews should work even if Full Access isn’t granted.
Has anyone had any experience with putting a UITextView into a keyboard extension not running with Ful Access?