Anyone know how to detect the "delete" key using UIKeyCommand
on iOS 7?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
Simple really - need to look for the backspace character "\b"
You can always try UIKeyInput. https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIKeyInput_Protocol/index.html#//apple_ref/occ/intfm/UIKeyInput/deleteBackward
The function should be
- (void)deleteBackward
As people were having problems with Swift, I figured a small, complete example in both Objective C and Swift might be a good answer.
Note that Swift doesn't have a
\b
escape character for backspace, so you need to use a simple Unicode scalar value escape sequence of\u{8}
. This maps to the same old-school ASCII control character number 8 ("control-H", or ^H in caret notation) for backspace as\b
does in Objective C.Here's an Objective C view controller implementation that catches backspaces:
And here's the equivalent view controller in Swift: