Categories
Swift Kick

How to dismiss the iOS keyboard when the user taps the “Return” key in Swift

dismissing ios keyboard with return key

A quick recap

A couple of weeks ago, I posted an article that showed how to program an iOS text field that takes only numeric input or specific characters with a maximum length in Swift.

It covered the Delegate pattern (something you’ll use often in iOS development), introduced the UITextFieldDelegate protocol, and showed you how to use one of its methods, textField(_:shouldChangeCharactersInRange: replacementString:), to intercept the characters that the user inputs into text fields.

zip file iconThe article included the Xcode project files for the featured app, ConstrainedTextFieldDemo. You can download it here [83K Xcode project and associated files, zipped]. When you run it, you’ll the screen pictured above, with text fields constrained so that they’d accept only characters from a specified set, or reject characters from a specified set.

Undocumented feature : Dismissing the keyboard when the user taps the “Return” key

One of the features that was included in the app but discussed only in passing was the dismissal of the keyboard when the user tapped the Return key. While this is convenient for the user, it’s not iOS’ default behavior. You have to watch for the event where the user taps the Return key, and then respond accordingly.

The UITextFieldDelegate protocol’s textFieldShouldReturn(textField: UITextField) method is called whenever the user taps the Return key while editing a text field. It accepts a single parameter, textField, which is a reference to the text field the user was editing when s/he tapped the Return key. It returns a bool — true if the text field should implement its default behavior for the Return key; otherwise, false otherwise. It’s where you should place code to intercept the Return key event.

What should that code be? If you remember only one thing from this article, let it be this:

The way to dismiss the iOS keyboard after the user is editing a text field is to make the text field resign its role as first responder.

What’s the first responder, you ask?

  • The short answer is that the UI object that currently has the first responder role in iOS is roughly analogous to the UI object that currently has the focus in other systems (such as Android, HTML, and .NET).
  • The long answer is that the first responder is the first view in the responder chain to receive many events. Most of the time, it’s the view in a window that an app deems best suited for handling an event. You can find out more by reading these Apple documents: Event Delivery: The Responder Chain and their Responder object documentation.

Take a look at code in the example app in my earlier article, particularly ViewController.swift.

Combining the textFieldShouldReturn(textField: UITextField) method and The One Thing You Should Remember From This Article, we get this method definition:

// Dismiss the keyboard when the user taps the "Return" key or its equivalent
// while editing a text field.
func textFieldShouldReturn(textField: UITextField) -> Bool {
  textField.resignFirstResponder()
  return true;
}

After all that preamble, the method itself seems pretty short and anticlimactic. This method lives in the ViewController class, which has adopted the UITextViewDelegate protocol…

class ViewController: UIViewController, UITextFieldDelegate {

…and in its viewDidLoad() method, it declared itself as the delegate of every text field in the corresponding view:

// Designate this class as the text fields' delegate
// and set their keyboards while we're at it.
func initializeTextFields() {
  vowelsOnlyTextField.delegate = self
  vowelsOnlyTextField.keyboardType = UIKeyboardType.ASCIICapable

  noVowelsTextField.delegate = self
  noVowelsTextField.keyboardType = UIKeyboardType.ASCIICapable
  
  digitsOnlyTextField.delegate = self
  digitsOnlyTextField.keyboardType = UIKeyboardType.NumberPad
  
  numericOnlyTextField.delegate = self
  numericOnlyTextField.keyboardType = UIKeyboardType.NumbersAndPunctuation
  
  positiveIntegersOnlyTextField.delegate = self
  positiveIntegersOnlyTextField.keyboardType = UIKeyboardType.DecimalPad
}

All this setup means that whenever the user edits any of the text fields in the view — whether it’s vowelsOnlyTextFieldnoVowelsTextFielddigitsOnlyTextFieldnumericOnlyTextField, or positiveIntegersOnlyTextField — and then hits the Return key, the textFieldShouldReturn(textField: UITextField) method gets called.

And when the textFieldShouldReturn(textField: UITextField) method, it does just two things:

  • It tells the text field to resign its first responder role (by invoking its resignFirstResponder() method). In this application, we want the keyboard to disappear when the user taps the Return key regardless of the text field, so we don’t bother trying to identify the text field; we simple call textField.resignFirstResponder().
  • Aside from dismissing the keyboard, we want the Return key to function as it normally would, so we have the method return true, which states that text field should implement its default behavior.

Resources

zip file iconOnce again, here are the zipped project files for the demo project, ConstrainedTextFieldDemo [83K Xcode project and associated files, zipped].

 

 

Categories
Uncategorized

Remote wipes and why you need a BYOD policy

The case of
Rajaee v. Design Tech Homes, Ltd.

smartphone - eraser on screen

In 2012, Saman Rajaee started work as a Houston-area salesman for Design Tech Homes, a Texas-based house-building firm. Design Tech didn’t provide mobile phones for their workers, and asked them to use their personal devices instead.

Rajaee used his iPhone 4 not only for work-related voice calls, but for work-related email as well. That meant connecting his iPhone to Design Tech’s Microsoft Exchange Server. Doing so requires an exchange (if you’ll forgive the pun) of privileges; in exchange for access to company resources from your mobile device, the server is granted the ability to enforce security policies on that device. One of those policies is remote wipe, which allows the server to completely erase the contents of a mobile device connected to it, and restoring it to its original factory “fresh out of the box” settings.

At the start of February 2013, Rajaee gave Design Tech his two weeks’ notice, and Design Tech immediately terminated him. A few days later, Design Tech’s system administrator issued the remote wipe command to Rajaee’s iPhone, which erased everything on it, both work-related and personal.

keep calm and i'll see you in court

Rajaee sued Design Tech, claiming that what they did caused him to lose contact information for hundreds of business contacts and family (much of whom lived overseas), business information, passwords, and irreplaceable personal data, including family photos and videos. He said in performing the remote wipe, Design Tech violated the Electronic Communications Privacy Act, the Computer Fraud and Abuse Act and Texas Theft Liability Act. In response, Design Tech filed a motion requesting a summary judgement.

The case was decided in Texas Federal Court, and Design Tech was able to get the case dismissed in November 2014. Their victory was based on these points:

  • A holding from the 5th U.S. Circuit Court of Appeals says that information that an individual stores on a hard drive or mobile device isn’t considered to be in electronic storage according to the definition of the term in the Electronic Communications Privacy Act (ECPA). The court determined that the personal data stored on Rajaee’s iPhone was not legally protected and hence his claim under the ECPA was dismissed.
  • To be considered a violation of the Computer Fraud and Abuse Act (CFAA), Rajaee needed to prove that the remote wipe caused him a loss of at least $5,000. Rajaee said that the personal photos, videos, and messages were worth more than that, but Design Tech’s lawyers were able to establish that Rajaee just couldn’t demonstrate that the loss of that data was worth $5,000 or more, nor was he able to show any evidence of costs incurred to investigate or respond to the remote wipe, which led to his claim under the CFAA also being dismissed.
  • The last leg of Rajaee’s case, the Texas Theft Liability Act, vanished since the court was a federal one and the law is a state law. The court declined to, in legalese, “declined to exercise supplemental jurisdiction over the remaining state law claims.”

lawyer showered in money

The only people who walked away happy from the case were the lawyers. Rajaee lost irreplaceable data and mementoes, not to mention time doing whatever re-setting up he had to do on his iPhone, and both parties spent time and money on the case, with Design Tech spending a lot of money on a big-name law firm.

What both sides did wrong

iphone 4

Rajaee’s biggest mistake is one that a lot of us make: failing to back up his phone. Even in those long-ago days of 2013 — that’s almost 10 internet years ago! — backing up an iPhone was pretty much an automatic process, either via services like iCloud, or plugging into your computer and backing it up through software like iTunes, which can be set up to do so automatically as soon as you hook up the USB cable. In a world where precious memories like personal photos and videos are digital and hard drive and cloud storage space is cheap and plentiful, you’re a fool if the one and only place they live is your phone.

remote wipe

Design Tech made a couple of mistakes. The first one was performing the remote wipe. Remote wipes are the nuclear option of mobile security. They’re meant to be used if and only if the phone is believed to be irretrievably lost, in which case it’s a security risk since it has access to corporate resources. Design Tech’s system administrator could’ve simply revoked Rajaee’s iPhone’s access to the Exchange server, which would simply make the Design Tech email messages, contacts, and calendar access disappear, without affecting or altering any of the phone’s other settings. Given that Design Tech’s response to Rajaee giving them two weeks’ notice was to terminate him immediately, it’s not hard to imagine them giving their sysadmin the order to issue the remote wipe command out of spite.

Design Tech’s second mistake was not having a mobile policy that its employees and contractors could agree to and sign.

Having a BYOD (Bring Your Own Device) policy is the best policy

signed policy

If your organization is going to allow employees to use personal mobile devices for work — that’s smartphones, tablets, and any other portable device that runs what’s considered to be a mobile operation system (Android, iOS, or Windows Phone, to cite a few examples) — you’ll need to:

  • First consider how you’d want employees to use their personal devices for work. Will they simply be taking voice calls? Accessing corporate email, contacts, calendar, or some combination of the three?
  • Write down those ways you’d want employees to use their personal devices at work in a BYOD policy. Spell out what is and isn’t acceptable use. State that when an employee connects his/her device to the corporate network and/or using it for company business, that s/he is granting access to the device to the organization.
  • Spell out the conditions that would necessitate revoking the device’s access to the corporate network. Spell out the conditions that would necessitate a remote wipe. If you don’t want to be a jerk, make it so that the conditions for a remote wipe are something akin to the device being irretrievably lost.
  • Educate employees about the BYOD policy, and make those who want to use their personal devices at work sign it.
  • Document everything: the policy itself, the processes and technology that enforces it, and the education process. Keep the signed policies in your records.

By having a BYOD policy, you can avoid the risk of a Rajaee v. Design tech Homes, Ltd. situation and save a lot of money, headaches, and your reputation.

If you need more convincing, take a look at our white paper titled No More Excuses: Why Your Business Needs a Mobile Policy. It looks at the most common excuses for not having one, which run the gamut from “I don’t know what to include in a policy” to “It’s an HR thing” to “We have BYOD”, and explains why they don’t let you off the hook. You’ll also get some first steps that you should take once you’ve said “no more excuses!”

this article also appears in the GSG blog

Categories
Uncategorized

My Marc Andreessen regret and his profile in The New Yorker

marc andreessen in the new yorker

Click the photo to read Marc’s profile in The New Yorker.

My Marc Andreessen regret

I have only a few regrets in my colorful career, and one of them not figuring out a way to turn the time Marc Andreessen reached out to me into something bigger.

In the fall of 2005, when I was just about to get married for the first time, I received an email from a “pmarca” from a domain I’d never heard of before. In the body, some guy claiming to be Marc Andreessen said that he was looking for a developer evangelist for a new company that was still in stealth mode. I initially dismissed it as a prank, but then thought better of it, and soon discovered that yes, it was the Marc Andreessen, and that company turned out to be Ning. A few email back-and-forths turned into a fantastic and fun phone interview with Gina Bianchini (Ning’s co-founder, and now entrepreneur in residence at Andreessen Horowitz) about becoming their North American developer relations guy, which included the possibility of moving to California to help them out with their venture.

A couple of weeks later, the possibility of that job had diminished greatly, as Marc and Gina had to get their burn rate under control. Marc suggested that I could take on the task of writing some example Ning apps, but I had so much going on between my job at Tucows and being newly-married to a wife who’d just moved to town and knew almost nobody. I figured that I didn’t have the bandwidth for the extra work — at least not without compromising the then-current job or the marriage. Those of you who know me know that the Tucows position is several jobs ago, and I’m now married to someone else, and every now and again, I kick myself for not finding a way to stay in the back of Marc’s mind for his later efforts.

Takeaways from Marc’s profile in The New Yorker, Tomorrow’s Advance Man

marc andreessen - vision and hallucination

Found at OnePowerfulWord.com. Click the picture to see the source.

The May 18, 2015 edition of The New Yorker features Tomorrow’s Advance Man, a profile of Marc Andreessen that also provides a look into his venture capitalist firm Andreessen Horowitz, VCs in general, and the money that stokes the machinery of Silicon Valley.

A quick cut/paste/save/wc says that it weighs in at a hefty 13,442 words and 67 minutes’ reading according to Read-O-Meter. Don’t let the tl;dr demon scare you away; it’s a worthwhile read. Spread it out over a couple of lunches or coffee sessions if you need to, because there are some insights that you’ll find useful if you’re the tech industry (as most of this blog’s readers are).

My top takeaways from the article are:

  1. Don’t take it from me, take it from Kevin Kelly: “If you are going to deal with VCs, this profile of Marc Andreessen with fill in the blanks. Long but worth it.”
  2. I knew about Andreessen Horowitz’ short name for itself — a16z — derived from the fact that there are 16 letters between the starting “A” and the closing “z”. It borrows from the term i18n, which shortens the word internationalization in the same manner. What I didn’t know was the short name that A16z’s competitors preferred: AHo, as in “a-hole”.
  3. Want to get media attention? Be noisy on Twitter. Marc tweets more than 100 times a day because “Reporters are obsessed with it. It’s a like a tube and I have loudspeakers installed in every reporting cubicle around the world.” If you’d like to see examples, see A16z’s list of Marc’s top tweetstorms of 2014.
  4. Reading between the lines — a strength that many technically-oriented people lack, and even the most-people savvy forget how to do so in stressful situations — is doubly important when dealing with VCs. They speak euphemistically, often using understatement as a weapon, writes the article’s author, Tad Friend. “You’re definitely going to get funded!” means “But not by us.” “Who else is in?” means “Besides not us.” And “I’m not sure I would ever use your product myself” means “So long!”
  5. Marc grew up far from any major tech center, growing up in Wisconsin in an atmosphere of “antiquity, superstition, frustration, and penury”. Tad Friend writes that his vision of the future came from television, with Star Trek and the decidedly less cerebral (but still inspiring) Knight Rider. Even today, he still seems to get some inspiration from TV, as the references to the TV series Halt and Catch Fire, which Marc and Tad watched together, indicate.
  6. He’s an optimist who thinks big, and in order to get his attention, you’d better be ready to do the same: “We’re not funding Mother Teresa. We’re funding imperial, will-to-power people who want to crush their competition. Companies can only have a big impact on the world if they get big.”
  7. The real problems are never the technical ones. The people issues are always waaaay more complex.
Categories
Uncategorized

Some days, it feels like this…

welcome to my world

…and I think I’m gonna need a bigger shovel.

Adapted from Pete Cheslock’s graphic, which I found I found via Leigh Honeywell.

Categories
Swift Kick

My “How to work with dates and times in Swift” articles (so far)

dates and times in swift

My articles on working with dates and times in Swift have steadily been getting more readers, so I thought I’d gather all the links to them in one place and make them easier to find. I’m also in the process of gathering the content of these articles and pulling them together into a date/time utility module, which I’ll post on GitHub. I’ll let you know when that happens!

In the meantime, my “How to work with dates and times in Swift” articles (so far):

A very brief introduction to date formatting in Swift and iOS: The oversight in a mostly-good book on Swift programming led me down the path of writing articles about dates and times in Swift, starting with this one, where I look at NSDateFormatter.

How to work with dates and times in Swift, part one: An introduction of Cocoa’s date and time classes, and how they work together. This article covers UTC (Coordinated Universal Time), and the key classes: NSDate, NSCalendar, NSDateComponents.

How to work with dates and times in Swift, part two: Calculations with dates: Now that we’ve got the basics, it’s time to do some date arithmetic: comparing two dates to see which one is the earlier and later one, finding out how far apart two dates are, and adding and subtracting from dates.

How to work with dates and times in Swift, part three: Making date arithmetic more Swift-like: Cocoa’s date and time classes have an Objective-C heritage, which in the Swift context, feel kind of clunky. In this article, I look at ways — and by ways, I mean helper functions and class extensions — to make date calculations feel more like Swift.

How to work with dates and times in Swift, part four: A more Swift-like way to get the time interval between two dates: This quick article shows you how to make an operator overload that makes getting the time interval between two dates more like subtraction.

Click the chart to see it at full size.

Categories
Uncategorized

Telecom history lessons: RIP Joseph Lechleider, and HP’s history of telecom in 3 minutes

RIP Joseph Lechleider, who came up with the idea behind ADSL

If you have one of these — often called a “DSL modem”, but it’s more likely to be a DSL router — in your home or office…

dsl modem

…then you have this engineer to thank:

joseph lechleider

This is Joseph Lechleider, who used to be an engineer at Bellcore, Bell Telephone’s research wing formed after it was broken up into the “Baby Bells”. In the late 1980s, he came up with a clever solution to a problem that came with trying to send high-speed electronic signals over ordinary copper wire and into this familiar connection:

rj-11

Electricity and magnetism are bound together in interesting ways, and this connection turns up when you send a current through a wire. The current induces a magnetic field around the wire:

current and magnetic field in a wire

The tight connection between electricity and magnetism means that the reverse is true as well: put a wire into a magnetic field, and you’ll induce a current in it.

This behavior made it difficult to send high-speed signals through copper wires, which to this day often make up the “last mile” between your wireline carrier and you. The magnetic fields induced by sending signals at very high speeds create a lot of interference, which mangles the data being carried, which slows down the rate at which you receive actual usable data.

Lechleider’s solution to this problem was both simple and clever: why not make it so that downloading (getting information from the network to you) was faster than uploading (sending information from you to the network)? This arrangement reduced the interference between the upload and download channels and offered more than twice the bandwidth that transmitting and receiving at the same rate did. His idea got incorporated into what we now know as ADSL (the “A” is for asymmetric), a key part of DSL service

The “receive data much faster than you transmit it” solution is an engineer’s dream: it’s clever, and it’s cheap, because it doesn’t require much change to existing infrastructure. It meant that phone companies didn’t have to spend a lot of money to provide broadband service, and it’s how DSL became popular. As recently as the end of 2012, it was the primary means of access for almost 60% of the world’s wireline broadband subscribers.

Lechleider died at home in Philadelphia on April 18th from cancer of the esophagus. We didn’t want his contribution to telecommunications to go unnoticed.

For your work in changing wireline broadband — as well as the way we live, work, and play — we thank you, Mr. Lechleider.

HP’s history of telecom in just three minutes

telecom history in just 3 minutes

this article also appears in the GSG blog

Categories
Uncategorized

iOS 8’s built-in virtual keyboards on the iPhone: A visual catalog

ios 8 keyboard

It’s been over two years since I published my visual catalog of iOS’ virtual keyboards on the iPhone, which covered iOS 6. At the time, it was the only place you could get a listing of the names of the iOS keyboards and see what they looked like. Even now, I think it’s still the only information source of its kind.

We’re now well into iOS 8’s run, and it’s likely that iOS 9 will be released sometime this year. Since there still isn’t a visual catalog of iOS 8’s built-in keyboards on the iPhone, and since I’m still of the “see a need, fill a need” ethos, I put one together. It starts with a table listing all the built-in keyboard types; you can click on the name to jump to pictures of all the views for the corresponding keyboard.

I hope you find it useful!

iOS 8’s built-in virtual keyboards

UIKeyboardType Based on Emoji entry? The official description, straight from Apple’s documentation
ASCIICapable Typewriter No Use a keyboard that displays standard ASCII characters.
DecimalPad Phone No Use a keyboard with numbers and a decimal point.
Default Typewriter Yes Use the default keyboard for the current input method.
EmailAddress Typewriter Yes Use a keyboard optimized for specifying email addresses. This type features the “@”, “.” and space characters prominently.
NamePhonePad Typewriter and phone Yes Use a keypad designed for entering a person’s name or phone number. This keyboard type does not support auto-capitalization.
NumberPad Phone No Use a numeric keypad designed for PIN entry. This type features the numbers 0 through 9 prominently. This keyboard type does not support auto-capitalization.
NumbersAndPunctuation Typewriter No Use the numbers and punctuation keyboard.
PhonePad Phone No Use a keypad designed for entering telephone numbers. This type features the numbers 0 through 9 and the “*” and “#” characters prominently. This keyboard type does not support auto-capitalization.
Twitter Typewriter Yes Use a keyboard optimized for twitter text entry, with easy access to the @ and # characters.
URL Typewriter Yes Use a keyboard optimized for URL entry. This type features “.”, “/”, and “.com” prominently.
WebSearch Typewriter Yes Use a keyboard optimized for web search terms and URL entry. This type features the space and “.” characters prominently.

iOS 8 features a total of 11 built-in virtual keyboards, all of which are variations on two basic types: the typewriter keyboard and the phone keypad, both pictured below:

typewriter and phonepad - light

Typically, the keyboard isn’t shown until the user taps on a text field or text view. You can specify the type of keyboard for a text field or text view visually in Interface Builder…

choosing keyboards in interface builder

…or you can do so in code using the text field or text view’s keyboardType property and values from the UIKeyboardType enum:

vowelsOnlyTextField.keyboardType = UIKeyboardType.ASCIICapable
noVowelsTextField.keyboardType = UIKeyboardType.Default
digitsOnlyTextField.keyboardType = UIKeyboardType.NumberPad
numericOnlyTextField.keyboardType = UIKeyboardType.NumbersAndPunctuation
positiveIntegersOnlyTextField.keyboardType = UIKeyboardType.DecimalPad

If you don’t specify a keyboard type for a text field or text view, the typewriter-based Default keyboard is used.

Thanks to their growing popularity (first in Japan, and then the rest of the world), many of these keyboards feature a way to enter emoji, which have been available on iOS since version 5, which was released in mid-2011:

emoji-light

All of iOS’ virtual keyboards come in both a light and dark appearance, with the light version being the default:

typewriter and phonepad - dark

As with the keyboard type, you can choose this appearance either visually in Interface Builder (via the Appearance menu) and in code using the text field or text view’s keyboardAppearance property and values from the UIKeyboardAppearance enum.

I haven’t been able to find anything in the Human Interface Guidelines on when the light and dark keyboards should or shouldn’t be used, so let your common sense be your guide, keeping in mind this fact about common sense:

Click the image to enjoy Deadpool’s wisdom at full size.

UIKeyboardType.ASCIICapable

This used to be the default keyboard; now it’s the “no-nonsense alphanumeric keyboard”. It lets you enter letters, numbers, punctuation, and symbols, and nothing else. Use this keyboard if you need the user to enter something that’s completely or primarily letters and don’t want them to enter emoji and especially for data entry in business, productivity, scientific, health, and other “serious” apps.

Primary view (accessed via the ABC key):

ascii-1-light ascii-1-dark

Alternate view 1 (accessed via the 123 key):

ascii-2-light ascii-2-dark

Alternate view 2 (accessed via the #+= key):

ascii-3-light ascii-3-dark

UIKeyboardType.DecimalPad

Use this keyboard if you want the user to enter either whole or fractional numbers. This keyboard provides the decimal separator appropriate for the user’s locale; the screenshots below show my locale settings, English/US. Note that there’s no return key of any sort on this keyboard.

decimalpad-light decimalpad-dark

UIKeyboardType.Default

If you don’t specify the keyboard type, you get this one, which lets the user enter letters, numbers, punctuation and symbol characters, and emoji. This is the most general-purpose keyboard in iOS.

Primary view (accessed via the ABC key):

default-1-light default-1-dark

Alternate view 1 (accessed via the 123 key):

default-2-light default-2-dark

Alternate view 2 (accessed via the #+= key):

default-3-light default-3-dark

Alternate view 3 (accessed via the the 😀 key):

emoji-light emoji-dark

UIKeyboardType.EmailAddress

If you want the user to provide an email address, this is the preferred keyboard.

Primary view (accessed via the ABC key):

email-1-light email-1-dark

Alternate view 1 (accessed via the 123 key):

email-2-light email-2-dark

Alternate view 2 (accessed via the #+= key):

email-3-light email-3-dark

Alternate view 3 (accessed via the the 😀 key):

emoji-light emoji-dark

UIKeyboardType.NamePhonePad

For fields where you want the user to enter data without punctuation — typically names or integers — use the NamePhonePad keyboard. It features typewriter-style input for entering letters, and phone-style input for entering numbers.

Primary view (accessed via the ABC key):

namephone-1-light namephone-1-dark

Alternate view 1 (accessed via the 123 key):

namephone-2-light namephone-2-dark

Alternate view 2 (accessed via the the 😀 key):

emoji-light emoji-dark

UIKeyboardType.NumberPad

This is amother numeric entry keyboard. It lets the user enter digits, but not the decimal separator.

Note that there’s no return key of any sort on this keyboard.

Primary view:

numberpad-light numberpad-dark

UIKeyboardType.NumbersAndPunctuation

Think of this as the ASCIICapable keyboard, but with an emphasis on numeric entry. Like the ASCIICapable keyboard, it lets you enter letters, numbers, punctuation, and symbols, and nothing else.

Use this keyboard if you need the user to enter something that’s primarily numeric but may also include letters, symbols and punctuation, but not emoji. You’ll find it especially useful for numeric data entry in business, productivity, scientific, health, and other “serious” apps. You should also use this keyboard when you want the user to enter numbers in scientific notation.

Primary view (accessed via the 123 key):

numbersandpunc-1-light numbersandpunc-1-dark

Alternate view 1 (accessed via the ABC key):

numbersandpunc-2-light numbersandpunc-2-dark

Alternate view 2 (accessed via the #+= key):

numbersandpunc-3-light numbersandpunc-3-dark

UIKeyboardType.PhonePad

If you want the user to enter a phone number or a touch-tone sequence, this is the preferred keyboard.

Primary view (accessed via the 123 key):

phonepad-1-light phonepad-1-dark

Alternate view 2 (accessed via the +*# key):

phonepad-2-light phonepad-2-dark

UIKeyboardType.Twitter

If you want the user to enter a tweet, this is the preferred keyboard.

Primary view (accessed via the ABC key):

twitter-1-light twitter-1-dark

Alternate view 1 (accessed via the 123 key):

twitter-2-light twitter-2-dark

Alternate view 2 (accessed via the #+= key):

twitter-3-light twitter-3-dark

Alternate view 3 (accessed via the the 😀 key):

emoji-light emoji-dark

UIKeyboardType.URL

If you want the user to enter a URL, this is the preferred keyboard.

Primary view (accessed via the ABC key):

url-1-light url-1-dark

Alternate view 1 (accessed via the 123 key):

url-2-light url-2-dark

Alternate view 2 (accessed via the #+= key):

url-3-light url-3-dark

Alternate view 3 (accessed via the the 😀 key):

emoji-light emoji-dark

UIKeyboardType.WebSearch

This keyboard is very similar to the Default keyboard, with two notable differences:

  • There’s a . key in the bottom row
  • The return key is blue, and by default is labelled Go.

It’s meant for entering both URLs and web search terms, but it’s equally useful for any kind search or even typed commands.

Primary view (accessed via the ABC key):

websearch-1-light websearch-1-dark

Alternate view 1 (accessed via the 123 key):

websearch-2-light websearch-2-dark

Alternate view 2 (accessed via the #+= key):

websearch-3-light websearch-3-dark

Alternate view 3 (accessed via the the 😀 key):

emoji-light emoji-dark