1

I have a UITextField and i want it be able to enter multiple email addresses. I want the functionality as line in MailComposer.

what I actually want is when user clicks a button i want to show address picker to select emails

Is there any predefined pickerView for that?

How can I do that?

user1244311
  • 191
  • 1
  • 2
  • 14

1 Answers1

0

One way might be to define a UITextField that is transparent on top of a UIView that can have other views as subviews. When you start typing an address you get textField:shouldChangeCharactersInRange:replacementString: in the UITextFieldDelegate. If the partial string matches then you can create a new UIView for each matching address and dynamically present them as options to be clicked/tapped to accept. You would probably use resizableImageWithCapInsets to create the bubble that the name sits on to allow for variable lengths. This list might change with every character.

If a choice is accepted then you would move the UIView containing the accepted address into the right position in the address line, to the left if there are no previous addresses, or after the last one if there are. Any other addresses shown would be dismissed at that time. Animation might look nice here. Then the frame of the UITextField would be altered so that text entry would take place after the UIView showing accepted addresses. It all looks like a UITextField, but it's not.

Other things to do would be to add a X button to each address allowing them to be removed. You could even parse the text as it is entered, if you have a good email address parser, turning text into bubbles and moving them up to the left with accepted addresses.

Adam Eberbach
  • 12,309
  • 6
  • 62
  • 114