Hey Guys,
In this post I’m going to show you how to create a custom keyboard in iOS 8. Now you’ll probably ask, why do we need a custom keyboard, why not just use the stock iOS keyboard?
Well, there’s a number of reasons why a custom keyboard is better than the stock iOS keyboard. For starters:
However the most basic functionality that should be implemented in any keyboard is the ability to respond to tap gestures and provide text in the form of an attributed string, and also, the ability to switch to another keyboard if you wish to do so, something that’s missing in the stock iOS keyboard.
Some of the most common keyboard features that iOS users expect include:
The ability to change the keyboard according to the UIKeyboardType.
At the moment, there’s no APIs available that you can use to add the above features to the stock iOS keyboard, so you need to build a custom keyboard if you want to avail these features.
Custom keyboards do have their limitations however, as there a number of stock iOS keyboard features that won’t be available to you in a custom keyboard. Features like:
So if those are features you use quite frequently or simply must have, then you should probably stick with the sock iOS keyboard. Otherwise have a look at the tutorial below to build your very own custom keyboard.
To build a custom keyboard you’ll first need to create an API for it. The illustration below depicts the various components that you’ll need to create as part of the custom keyboard API.
UIInputViewController – this is the primary view controller of your custom keyboard that controls the keyboard and responds to user events. It utilizes the following properties, functions, methods and controllers:
Oh and if you want to disable the custom keyboard interaction in your app and just want to use the stock iOS one instead, you can use the following app delegate.
- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier
{
if ([extensionPointIdentifier isEqualToString:UIApplicationKeyboardExtensionPointIdentifier]) {
return NO;
}
return YES;
}
Alright, let’s get started with our tutorial for creating a custom keyboard. Here’s the steps you’ll need to follow.
Step 1: Create a New Project
Open XCode 6 and create a new Single View Application (as shown below)
Step 2: Add a Text Field
Next, open the Main.storyboard and drag a text field from the Objects Library (this is the text field you’ll use to test the keyboard later). Now, center the text field and add the necessary layout constraints as shown below.
Step 3: Add the Keyboard Extension
Now, select the project file in the Project Navigator and add a new target by clicking the ‘+’ button at the bottom.
Next, select the Application Extension on the left and choose the Custom Keyboard template as depicted below.
Now lets run the Application. When you do that you’ll notice the following screen.
When you select the text field on this screen, you’ll see the standard iOS keyboard appear. Press and hold the globe key on the iOS keyboard to display the list of keyboards. When you do that you’ll see the following screen.
You’ll notice that the custom keyboard you created is not visible in the list. That’s because you need to first install it through the settings App before you can access it from the iOS keyboard’s globe key.
To do that go to go to Settings > General > Keyboard > Add New Keyboard. And then select the Folio3Keyboard App, as depicted in the screenshots below.
Now go to your app again and try tapping the the Globe key in the iOS keyboard.
You’ll notice that your custom keyboard is now showing in the list of available keyboards. Please note that this keyboard only has the ability to switch to a custom keyboard if you have one. You will have to add other functionalities like typing, backspace etc. yourself.
As a leading mobile app development company (iPhone, Android, Windows Phone, HTML5 app development), Folio3 specializes in native app development services and cross platform mobile app development services for the iPhone and iPad. We also offer extensive mobile app testing and QA services. If you have a mobile app idea that you’d like to discuss please or would like to know more about our iPhone app development services, please Contact Us. Learn more about our iPhone, Android and Windows Phone app development services.
USA408 365 4638
1301 Shoreway Road, Suite 160,
Belmont, CA 94002
Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.
Tel:
+1 408 365 4638
Support:
+1 (408) 512 1812
COMMENTS ()
Tweet