'Cmd+B in UIKeyComands not displaying first typed "b" afetr using the command - swift
I'm using UIKeyCommands - Cmd+B to bold text. The code works fine to bold the text. But after i use the Cmd+B and when I type "b" the first time it doesn't display on my textView.
Here's the code:
override public var keyCommands: [UIKeyCommand]? {
let commands = [ UIKeyCommand(input: "B", modifierFlags: .command, action: #selector(keyTapped(command:)))]
return commands
}
@objc private func keyTapped(command: UIKeyCommand) {
if command.input == "B" && command.modifierFlags == .command {
print("Bold text")
}
}
How do I fix this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|