Detect UITextField autosuggestion text replacement - ios

The problem I have is that I want to detect when the UITextField's text is being changed when the user taps on autosuggestion word.
Using textFieldShouldChangeTextinRange will also react to pasting any text from clipboard, but I want to process EXACTLY the autosuggested text replacement.

It is not possible, there is no UITextfield's delegates to implement it.

Related

UITextView responding unexpected to accessibility voice over

Currently I am walking through my whole iOS app to optimize it for accessibility voice over. When it comes to the UITextView, which I subclassed, voice over is not acting like I thought it would. My UITextView subclass is only changing a path's color on the superview's layer in becomeFirstResponder and resignFirstResponder. So nothing special on my UITextView subclass that could interfere with accessibility.
As long as there is no text in the UITextView it is acting as expected. Voiceover tells me that it is a text field and that I can double tap it to edit. But as soon as there is text in the UITextView, the only thing voice over tells me, is the value of the UITextView. Voice over doesn't tell me anymore that this is an editable text field.
Am I doing something wrong? Why is it acting like that?
I do appreciate any help!
If you didn't edit any accessibility hints or labels for the text field it should act accordingly. If selected it should say:
It is a text field
If you are editing it
The editing mode you are in
The value of the text field (nil if empty)
Where the cursor is
Then while you type it says the letters you are entering as you enter them. When you hit space or enter it should say the word you just typed. As long as your text field is exhibiting these behaviors you should be fine.
Tip: if you want to know how accessibility elements should act, try using a native iOS app with accessibility turned on and compare it with your app.

Keyboard with only number and letters input for username field?

I have a textfield and I would like to remove the punctuation marks from the keyboard and also the spacebar. Can this be done?
AFAIK, you cannot remove anything from the keyboard without providing your own custom keyboard. You may however, intercept characters before they appear in the textfield using it's delegate method -(BOOL)textField: shouldChangeCharactersInRange: replacementString:. (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextFieldDelegate_Protocol/index.html#//apple_ref/occ/intfm/UITextFieldDelegate/textField:shouldChangeCharactersInRange:replacementString:)

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)

How to implement a UITextField similar to email Text Field in MFMailComposeController

In MFMailComposeController, once we start typing, the list of email addresses is shown. Once we select, the TextField displays the name of the user with a small Oval background. Then we can continue typing. If we want to delete it, then pressing backspace selects the oval background and on second backspace the email address is deleted. How can this be implemented.
I am not interested in the search part. I am fine with Implementing it. But I am more interested in getting the TextField working as in the MFMailComposeController. The way the blue oval background is set for already typed in emails.
Thanks
If you simply want to search through a set addresses,strings or whatever you can implement UISearchDisplayController and you will getyour job done.Here's the link on UISearchDisplayController iPhone.
Else , if you want to have youown you have will have to have a UITextField with a UITableView and you will have to implement the delegates method of UITextField to get the autocomplete feature searching through tableview's datasource.Implement your logic using delegates of UITableView and UITexField.
you can use many open source implementation one name from them is TITokenFieldView.

copy text from textfield with not enabling keyboard

i have a uitextfield and some text on it, i want to know how to create a code that my user touch the field and can copy the txt to use for something else.
my uitextfiled.enable = no;
thanks
As far as the copying goes, you need to check out the UIPasteboard Class. Using that class, you can put text onto the pasteboard very easily.
For not enabling the text field, you can simply leave it disabled, but capture the touch event anyway.
For the pasteboard, try going through this tutorial.
I you are able to use UITextField class instead you could set the editable property to NO. Selecting text will still be possible.

Resources