How to set a custom keyboard for UIWebView - ios

How to show a custom keyboard and Input Accessory View for a editable UIWebView for iOS7 and up.
i.e: How can i set and make use a value from [UIWebView setInputView:] and [UIWebView setInputAccessoryView:]

It would be helpful to understand what you're trying to do? You can either be trying to force a specific type of keyboard such as numeric, email, etc. that will use the keyboard the user has explicitly installed on their device (or the system one).
In order to do this, you can reference this apple doc which shows you the 'type' attribute to add to an tag.
Otherwise you are asking about loading a custom keyboard that you have created from the webview. The app developer in me screams, "you should NEVER do this." If you're content is generic enough to merit putting into a webview, than it is certainly not worth loading a custom keyboard.
If you realllly need to do this, you can set keyboardDisplayRequiresUserAction to NO, then use custom javascript to request the app to perform a native function, then drop a uitextfield or uitextview directly overtop the html input field and set a custom input view on the native control. There are an obscene amount of problems with following this approach, and I sincerely hope you

Are you trying to customize the ios keyboard or you want to show an HTML keyboard?
In the first case you can look at this link: link
In the second case you can just google for it, this is the first result searching for "html keyboard".
Good luck

I believe there is no way to do this as of now. Hence, my current approach is to use a custom view below the keyboard and hide the keyboard and show the keyboard as required.

Related

Editing a Keyboard in iOS

In terms of application for iOS coding, how can you manipulate the pre-existing keyboards? I want to change a button on the keyboard (for example, the A button on the English key board) to a custom image and custom output.
So I guess what I'm asking is: if and how you can access a pre-existing keyboard and if you can change the output of one of the keyboard buttons to a custom image which others will see if you send it to them?
Can't be done. There is no way to alter standard keyboards. You can add toolbars above them (via inputAccessoryView), you can't alter the actual keyboard.
You would need to create your own custom keyboard.

IOS 8:custom Keyboard with undo and redo button

I have developed an IOS 8 custom keyboard. I want to give it "undo" and "redo" functionality, like the default system keyboard. I have tried it in different ways but was unable to find a good solution.
We can interact with a Text Input Object textDocumentProxy with the methods
insertText
deleteBackward
documentContextAfterInput
ocumentContextBeforeInput
But I was unable to find any way of implementing "undo" and "redo" functionality.
I think we can NOT implement these function (undo,redo)
According to https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html
Because a custom keyboard can draw only within the primary view of its
UIInputViewController object, it cannot select text. Text selection is
under the control of the app that is using the keyboard. If that app
provides an editing menu interface (such as for Cut, Copy, and Paste),
the keyboard has no access to it. A custom keyboard cannot offer
inline autocorrection controls near the insertion point.
I think there are many case that content of textfield changed and you can not know when it changed, how it changed. If we can not know, we can not know to undo to where too. I think so.
I'm developing Custom keyboard extension like you and I have many problems. (eg: how can we know the current cursor to get current text selection...)
My question: Current text selection in CustomKeyBoardExtension (hope somebody know)

Editing keyboard layout in iOS

Is there a possibility to change the button layout on a pre-made ios keyboard?
I would like to add "done" and "punctuation" buttons to numeric keyboard.
There is the Decimal Pad available but in this case i would have to add a custom done button at the top.
Is there a way to move the "delete" button to the right and make it half of its current width, put next to it the "decimal" button and on the former place of "delete" locate "done"?
No, you'll have to implement your own keyboard, if you duplicate the Apple one it will get rejected.
iOS does not support making those types of changes to the keyboard, the only thing you can do is change the text associated with the Done/Enter button by changing the UIReturnKeyType of the associated UITextField.
You can make a View With the buttons you want and set the inputView to the custom view you made ,, and you got a custom keyboard :D
You cannot directly modify the keyboard other than by choosing one of apple's presets. However, it is possible to add additional keys above it using -inputAccessoryView, like WolframAlpha has done in its app.
It looks like you can replace the keyboard entirely, but the accesory view is probably the way to go. See the answer to Adding key to IPad keyboard
EDIT: For an example of how this would look, check out WolframAlpha's blog post on the subject. In your case the accessory view probably won't be quite so tall

How can I get the size of the keyboard on iPhone?

I want to get the keyboard size without using NSNotification. When I press the plus button, it can replace the keyboard with a custom UIView like this:
Then the plus button is pressed and the view loaded:
How can I achieve this?
I already made same rookie mistake like you want to do here. The problem is you will write a lot only to realize you do not want to avoid standard flow provided you by iOS team. For example you will definitely have a bad time dealing with issue like this one (there is additional bar which is part of standard keyboard for Chinese locale):
I solved this by using other people's work from DAKeyboardControl project. You do not need to attach observer (or if you use DAKeyboardControl - block) directly to your bar with buttons, but to your controller and check what user is trying to do and animate this bar accordingly. In the sources you can see how to get keyboard's animation duration and timing function. It may sound more complicated than it indeed is, just give it a try.

Custom keyboard with regular keyboards?

I'm creating an app that uses a custom keyboard, now if I provide the default English keyboard using the same globe icon that iOS uses, it should be able to switch to the default English keyboard fine, but I'm not sure if the user can return back to my custom keyboard from the system keyboards (assuming the user has more than 1 keyboards).
Can someone please confirm if that would be possible?
Thanks
It's not. the system keyboards have no "switch to custom keyboard" button. They're not even aware you made a custom keyboard.
What is it you're trying to accomplish? Why are you building a custom keyboard? If you tell us, maybe we can suggest an alternate way to do what you need to do.
You should set an inputAccessoryView in your UITextView with a button to toggle between your custom and the standard keyboards.
Every time the user taps the button you change myTextView.inputView between your custom keyboard and nil, which restores the original keyboard.
https://developer.apple.com/library/ios/documentation/uikit/reference/UITextField_Class/Reference/UITextField.html#//apple_ref/occ/instp/UITextField/inputView
You'll also need to reassign first responder, and also try to animate it if you want:
Animating UITextInput's textInputView
What you need is making a custom keyboard check this:
App Extension Programming Guide

Resources