Question

In some applications like Mail, when you have a UITextField, there is a little + button to the right. When you tap it, a modal view controller comes up which you can select a phone number, address, etc from, and it will appear in the text field. I was wondering how to implement this in my own app. Thanks,
Isaac

Was it helpful?

Solution

If you want the plus button inside the text field, take a look at the rightView property of the UITextField class, which lets you put any UIView in the right-most portion of the text field. You can put a UIButton there, as created with

[UIButton buttonWithType:UIButtonTypeContactAdd];

OTHER TIPS

You can do this by

txtFldObj.rightView = [UIButton buttonWithType:UIButtonTypeContactAdd];

txtFldObj.rightViewMode=UITextFieldViewModeAlways;

you can also refer to this trick also

You can do this by having a regular UIView that contains a UITextField and a UIButton as subviews.

E.g

-------------------------------
| UITextField       | UIButton|
-------------------------------

When the button is tapped you can bring up the address book picker (or anything else) as a modal view, and when it closes update the text field as necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top