Is it possible to present a Context Menu alongside software keyboard?
I'm trying to present context menu via tapping a button while locking focus on a UITextField in the meantime. But found out whenever the context menu is presented, keyboard is automatically dismissed. Even strangely, canResignFirstResponder() and resignFirstResponder() are not called at all.
Sample code:
I'm trying to present context menu via tapping a button while locking focus on a UITextField in the meantime. But found out whenever the context menu is presented, keyboard is automatically dismissed. Even strangely, canResignFirstResponder() and resignFirstResponder() are not called at all.
Sample code:
Code Block swift class TextField: UITextField { override var canResignFirstResponder: Bool { print(#function) return false } override func resignFirstResponder() -> Bool { print(#function) return false } } class ViewController: UIViewController { @IBOutlet var textField: UITextField! @IBOutlet var button: UIButton! override func viewDidLoad() { super.viewDidLoad() button.menu = UIMenu(title: "", children: [ UIAction(title: "Hello") { _ in } ]) button.showsMenuAsPrimaryAction = true } override var disablesAutomaticKeyboardDismissal: Bool { print(#function) return true } }