Custom Keyboard in iOS 8 - ios

iOS 8 lets us create our own custom keyboards.
Is it possible to make a custom keyboard output anything other than unattributed NSStrings?
Can I make a keyboard that outputs images to say the Messages app, or is it impossible?

No, this would be too difficult since most UITextField / UITextView can only handle NSString object.
As described in the UITextDocumentProxy only NSStrings are allowed.
UITextDocumentProxy is the communication object used by UIInputViewController. UIInputViewController seems to be the base for creating custom keyboards.
Also have a look at App Extension Programming Guide
- Custom Keyboard

You can create a twitter-style workaround: when the user selects an image, you upload it to your server and send a shortened url in reponse. this shortened url will be inserted to the text view of the host app and good luck :)

Related

Nativescript iOS Action Bar Subtitle

I'm attempting to put a subtitle under a title in the action bar on iOS. While there is this solution for Android it doesn't work on iOS at all. Is there any way to do this on iOS?
<ActionBar [title]="This works" [subTitle]="I want a subtitle here"></ActionBar>
iOS doesn't have a subtitle option. But you could use a custom title view and wrap two labels one below another.
iOS has some sort of subtitle, but it is named as prompt (for more detail, you can see the doc for UINavigationBar).
Unfortunately, you can't set its value from XML, so you need to use some handler - I create simple playground to demonstrate prompt property.

iOS Custom Keyboard Types

I'm worked on a custom keyboard and Apple review team rejected it because the keyboard does not support 'Numbers and Decimals' types.
So, I found that the problem is that when a text field requires those specific type of keyboard (for example to inset age, measures, or other numeric values), my keyboard 'misses to respond'.
I understood, reading from Apple documentation, that you must respond to the UIKeyboardTpye property per text object's.
I searched for specific delegate of the UIInputViewController but I wasn't able to find something close to that.
In this forum I found that one good place to examine the current keyboard type required is the textDidChange: delegate, but, it is not called.
I suppose this responder is called when your keyboard, somehow, 'declares' to iOS that it can handle Numbers or Decimal types. In fact I created a simple app with a simple UITextView that requires the Decimal keyboard type:
textView.keyboardType = UIKeyboardTypeDecimalPad;
And I put a NSLog() in the keyboard extension Input View Controller textDidChange: delegate.
As I tap on the text view my delegate is not called, instead the standard Decimal keypad is shown and in the Xcode console I see the following message:
Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 405786210_Portrait_iPhone-Simple-Pad_Default
I noticed also that this message comes when the UITextView requires the not-allowed keyboard types, i.e. the phonepad. All other keyboard types do not issue that message and the custom keyboard is shown and the textDidChange: delegate is correctly called.
The Numbers and Decimal types are surely allowed and are a MUST for the review team guys. Why the behave as a forbidden-types?
I think we need to 'declare', for example in the info.plist that our extension supports various keyboard types, but... well or more simply... I do not get the point... so... I'm asking... How can I add multiple keyboard types to my keyboard extension??
Thank you very much for help!
After the second rejection of my keyboard extension they sent me a screenshot. I noticed that they, generally, test apps on iPad. This made me think.
After some test it came out that the Numbers and Decimal types do not respond the same way on iPhone and iPad.
On iPhone a text view requiring Numbers or Decimal type keyboard always shows the iOS keypad, i.e. the custom extension is not called.
On the other side, on the iPad a text view requiring Numbers or Decimal type keyboard activates the custom extension.
Finally, after provided a standard numeric keypad (even if my keyboard uses hand-written techniquies) it was approved.

Sending images with iOS 8 custom keyboard?

I've been developing a custom keyboard for iOS 8, but stumbled upon a problem trying to send images using the keyboard. I did some research and it seems like there isn't a simple way to do this with UITextDocumentProxy because only NSStrings are allowed.
Am I either overlooking any simple ways to use a custom keyboard to send images and/or is there any way to work around this issue?
Thanks in advance
Apparently, you are not the only person to try a keyboard like this. If you look at the animated GIF on the site, the keyboard uses copy/paste to add the image to the messages.
The UIKeyInput Protocol, which is inherited by UITextDocumentProxy, has the following function:
func insertText(_ text: String) //Swift
- (void)insertText:(NSString *)text //ObjC
These only take a String or an NSString, as you already know. Because there are no other methods to insert content, it can be assumed that, currently, there is no other way.
Right now, I would suggest that you adopt a similar usage. When the user taps on the image, add it to the UIPasteboard. Maybe present a little banner on top of the keyboard saying, "You can now paste" or something, but that would be up to you to decide.

How to show Emoji like skype in ios sdk

I am creating Chat Application. I want enable emoji symbols like skype in my application even thought the
Settings -> General ->Keyboard -> Add New Keyboard ->Emoji
Was not enabled in device.
I need to display the emoji like the above image. Please suggest me some ideas
Yes you can.
Directly assign emoji characters in control.
I have used \ue231 characters emoji as bullet in UITextView and UILabel.
lbltest.text=#"\ue231 Check this out!";
You can refer this link for getting supported emoji characters.
You try them. I think it useful.
http://code4app.net/ios/custom-emoji-keyboard/51395bee6803fa8427000000
http://code4app.net/ios/TSEmojiView/501229bd6803faa052000000

When is -[UITextInput selectionRectsForRange:] called?

I have an app with a custom text editor that implements the UITextInput protocol. In iOS 6, Apple added one new required method to the protocol:
- (NSArray *)selectionRectsForRange:(UITextRange *)range
I've implemented this, but I can't seem to find a way to trigger it. At least in the way my app works, it seems to never get called by the text system. Does anyone know what it's used for?
This method is only used by subclasses of UITextView. This is the only method that would give you the system selection and loupe. This is what I was told at WWDC.
I am working on my own DTRichTextEditor as well and I implemented it nevertheless, maybe one day we get the selection/loupes also for our own UIViews that are not derived from UITextView.

Resources