19991

How to change the keyboard type for a text field in Xcode

Question:

I created a text field in XCode, not Interface Builder. In IB you can select different keyboard types. How can you do the same thing in XCode?

Answer1:

How about the <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html#//apple_ref/doc/uid/TP40006896-CH3-SW12" rel="nofollow">keyboardType</a> property?

Answer2:

1) In xib you can change by clicking the Keyboard type like below

<a href="https://i.stack.imgur.com/GOlzm.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/GOlzm.png" data-original="https://i.stack.imgur.com/GOlzm.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

2) Programmatically you can set by textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;

Recommend

  • iPhone UIKeyboardTypeNamePhonePad with shift key
  • Ios Numeric keyboard with decimal
  • NSPredicate issue using with numberOfRowsInSection method
  • Using FocusNode in TextFormField Flutter
  • two interfaces, multiple inheritance combine into one container?
  • Is it possible to create prototype cells in Interface Builder without story boards?
  • Sorting an array of pointers
  • Trying to get all column names in a table
  • How to set the navigation bar to the top in Table View?
  • UIPickerView without IB?
  • Cassandra NoClassDefFoundError: com/google/common/util/concurrent/AsyncFunction
  • Comparing user's facebook/twitter friends to site's users in Python/Django
  • EditText is covered by Keyboard
  • Why can't UI components be accessed from a backgroundworker?
  • Motorola barcode scanner SDK events C#
  • SqlCommand back up Database
  • jQuery: How to AJAXify WordPress Search?
  • Android device acting as an accessory
  • Cast between interfaces whose interface signatures are same
  • Not able to aggregate on nested fields in elasticsearch
  • Firefox Extension - Monitor refresh and change of tab
  • C++ Partial template specialization - design simplification
  • Retrieving value from sql ExecuteScalar()
  • Javascript simulate pressing enter in input box
  • C# - Serializing and deserializing static member
  • Incrementing object id automatically JS constructor (static method and variable)
  • MySQL WHERE-condition in procedure ignored
  • ORA-29908: missing primary invocation for ancillary operator
  • Web-crawler for facebook in python
  • How to get next/previous record number?
  • KeystoneJS: Relationships in Admin UI not updating
  • trying to dynamically update Highchart column chart but series undefined
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Free memory of cv::Mat loaded using FileStorage API
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • How does Linux kernel interrupt the application?
  • unknown Exception android
  • Checking variable from a different class in C#
  • java string with new operator and a literal