Is there a way to add a cancel button to the keyboard displayed for UITextField
? Looking over the UITextInputTraits
Protocol Reference, I could not find anything, including trying out the different keyboard types.
相关问题
- 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
- Popover segue to static cell UITableView causes co
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
You can create a input accessory view which can display a UIToolBar Above the keyboard and then add a cancel button to this. Take a look at the documentation link below for the inputAccessoryView property.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextField_Class/Reference/UITextField.html
This is an example of one I did for a TextView. The create Input Accessory View method is called from "textViewDidBeginEditing". Then it creates the input accessory view and in my case adds three buttons and a space bar.
I hope that helps.
I just dropped a
UIToolbar
into my view controller in Interface Builder, then:Voila!
Andrew, how's it going? it's Dima R!
As far as I know, there is no great way to do what you're trying to do. You can easily pick from one of the built in types that are listed here
What you could do is either add a view on top of the keyboard that contains your cancel button, or try to traverse through the view hierarchy and overlay what you want on the button that way (although this method is unreliable). Unfortunately, this is one thing Apple has not provided much customization for yet.
edit: Actually I think I misread your question from the start, since you wouldn't want a cancel button as the main return button anyways. In this case, the input accessory view is definitely the way to go.