Adding custom text to UITextField buffer - ios

Background: I have got a custom alert part of the HomeKit API. I'd like to allow the user to paste the code requested rather than inputting it manually.
Whenever there is text in the buffer it is possible to paste it by tapping on the textfield. How can I add custom text (from my App) to "this" buffer so the "paste" option appears?

You can populate the iPhone clipboard using below code. Put this code to a suitable place in your code.
UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
clipboard.string = #"<Assign Some value>";

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.

Test if Button Text has changed

I have a button whose text changes based on certain criteria. I want to test this functionality with XCUITest but I can't seem to be able to access the text on the button.
I have tried
button.staticTexts
button.value
button.title
elementsQuery.buttons["My Button"] //This uses the accessibility label
How can I access the text?
I know this is old but try this:
let app = XCUIApplication();
let buttonText = app.otherElements["My Button"].staticTexts;
If this doesn't work let me know. Currently working on iOS XCUITests myself

How to create custom keyboard extension with images on it in Objective-C?

I am having an app in which I want to create my own custom keyboard.
In this custom keyboard, I want to put images.
Users can access this keyboard from anywhere in the device.
I want it like this Link.
I want to make a keyboard like this
I have searched a lot on this and I know there are lots of tutorials but most of those are in swift and another are not with keyboard extension.
I want proper guidance or any link of tutorial for this.
Any help would be highly appreciated.
Thanks...
So I got my answer from the below link which is a very nice tutorial in objective C.
Custom keyboard with extensions in objective c for ios8
Now, like I needed, if anyone wants to add custom images in it, you can just copy the image to the clipboard and paste the image where its needed.
For copying the png files, use the below code.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *imageName = [NSString stringWithFormat:#"%ld",(long)sender.tag];
NSString *newPathName = [[NSBundle mainBundle]pathForResource:imageName ofType:#"png"];
NSData *data = [NSData dataWithContentsOfFile:newPathName];
[pasteboard setData:data forPasteboardType:#"public.png"];
This public.png comes from http://www.escape.gr/manuals/qdrop/UTI.html
You can choose any extension type you want to.
The pasteboard type changes as per the image extensions.
Important note: For image sending, the Apps which gives an access to paste the image copied from clipboard, only from those apps images will be sent.
I did it with the above solutions. Hope it helps someone else also.
Thanks...
This question is several years old now, but if anyone has the same needs today, I have created a Swift library that helps you create keyboard extensions that support characters, operations like backspace, newline etc. as well as images. It also has support for copying images to the pasteboard and saving them to the photo album.
If you need a library like this, feel free to check it our here:
https://github.com/danielsaidi/KeyboardKit

UIPasteboard containing images AND text- pasting into Mail

Since iOS8, the behaviour of Mail with the pasteboard seems to have changed.
I am trying to copy both images and text from my app, in a format that I can paste into the Mail app.
A UIPasteboard containing both images and text will only paste the images into Mail. A pasteboard containing one or the other works fine.
I create a dictionary for each text and image element, add them all to an array, then set pasteboard.items to the array. This method has worked for a year or two.
My guess would be that Mail now takes the "best" data in the pasteboard, and assumes that the text was included only as a fallback (such as a text description).
Has anyone else observed the same problem, and is there a workaround?
When I tried to add some text and a image to the UIPasteboard a few days ago, I found that ONLY the image was added to the UIPasteboard.
UIPasteboard.generalPasteboard().string = text
UIPasteboard.generalPasteboard().image = image
I use the code above then check UIPasteboard.generalPasteboard().string was nil, I firmly sure that my text wasn't nil. So, this may be a bug.

Custom Keyboard in iOS 8

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 :)

Resources