custom keyboard - how to dispatch event which signals the UITextField to update the text accordingaly - iphone

I am trying to create a custom keypad through a collection of buttons, which function like a regular keypad provided in iphone.
Now series of action that should occur
-text field is selected
-user presses the button
-text field is designated as first responder
-something like key event is launched so that text field is updated according to the character associated with the button.
If above supposition of flow is correct, please guide me how to get around the last step. I am newbie to iphone, so please let me know if am missing any of the basic.

Found an other way which did the needed by simulating the behaviour of keyEvent( which i doubt if exist in iphone sdk).
Basic outline of the procedure is like
-push the content to pasteboard
-call the paste function on UITextField
so when button is pressed, content corresponding to the button is copied to pasteboard and then paste function is called on the UITextField, so that the content get inserted into it.
Detailed description of steps can be found here:
http://dev.ragfield.com/2009/09/insert-text-at-current-cursor-location.html

Related

Selecting all text in a UITextField when an user has VoiceOver enabled

In my App I have several text fields which a user can edit. If the text field already contains text and the user begins to edit the text field, I want to highlight all text, so it's easier for the user to delete the content of the field.
Searching the web I have found the solution to set the text fields delegate to self and use the function didBeginEditing(). In this function I just call textField.selectAll(nil). As long as I don't use VoiceOver on the phone this works well. As soon as you turn VoiceOver on the text in a textField doesn't get highlighted when beginning to edit the text field. The function didBeginEditing though is still called. I checked this with a simple print statement.
Has anyone an idea why this isn't working? Is there maybe another way to highlight all text in a text field?
Thank you for every answer!
The selection of text is lost when the VoiceOver selects the element. You should select the text after the VoiceOver focus on element.
On didBeginEditing you can check if
UIAccessibility.isVoiceOverRunning and then you select the text after one second.
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
self.textField.selectAll(nil)
}
Not the best solution, but it's working. Also, for a person with vision problem I don't think is useful to select all the text, eventually you should inform the user that the text is selected.

How to check whether all fields are empty in ABNewPersonViewController

I have a custom button in ABNewPersonViewController. I need to enable the button, only if any(at least) one of the fields in ABNewPersonViewController is edited. Is there any way in which I can check this condition, other than writing code to check all fields independently.
You'll need some code somewhere to do this, but I'd do it by coding the existing event listener on each field to enable the button when the field being listened to is edited.
All controls have events so you can link your code to it. Example: UITextField has the event Editing Did Begin. Every controls can be linked to the same IBAction and you can recognize wich control the user changed by checking the sender param.

Custom Pin Password Boxes on iOS

I want to create a 4 character custom password entry like the iPhone lock screen page. It's going to have a custom designed keyboard pinpad, but thats not the question. I have 4 boxes for the entry of the pin, and each box is separated and has its own custom design. I currently have a clear UITextView on top of each box. However, I'm not really sure how to link all these together so that when I enter a number in the first box, it automatically advances to the next box so I can type the next number. After the last number has been entered, it should automatically check to see if the password is correct and if so do some action. What is the best way to do this?
When implementing UITextFieldDelegate you should check on textField:shouldChangeCharactersInRange:replacementString:
and you can move keyboard focus to next UITextField via BecomeFirstResponder documentation
So on last UITextField you will hide keyboard and disable all UITextboxes automatically, but If I were you, I would prefer to provide button to start checking pin (to let user correct pin if mistyped)

New key on the keyboard

I work on a iPhone project with iOS 4 and Xcode 4.
In a view I have several UITextField, that the user fills with numbers. So only the Numbers keyword is used.
When the user fills in a text field and click Go, some processing is started (modification of the text of several textFields).
Now I would like to consider also a second option: user open the keyboard but then decides to close it without any process (i.e. cancel the process).
So I need a keyboard with a cancel key as shown on this the picture:
Finally my question: how can I create a keyboard with a cancel key as above?
Edit: picture of my view
The keyboard cannot be modified. You should add a cancel button, or some other way of triggering a cancel, in your UI.

UITextField Keep the placeholder text on while focused

I want to keep the place holder text shown while it is focused (that is, while it is the first responder). It should stay that way only until something is typed and the field no longer blank.
Address Book app's Search bar behaves like this, as do the new contact entry fields.
Is there any way to do that?
I don't think this comes "built in" for you to activate it, but you can build it rather easily on your own: Create a UILabel you want to display and when the focus is set onto the TextField place the UILabel at the right spot (slightly after the cursor).
As soon as the user enters a character you hide the UILabel. You can see when the user starts the edit and starts to type by adding your class as delegate to the UISearchBar (see callbacks "searchBar:textDidChange:" and "searchBarTextDidBeginEditing:"): http://bit.ly/eQlvRz