Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK - UITextField with + Button for Contacts

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

like image 713
Isaac Waller Avatar asked Mar 19 '09 20:03

Isaac Waller


2 Answers

You can do this by

txtFldObj.rightView = [UIButton buttonWithType:UIButtonTypeContactAdd];

txtFldObj.rightViewMode=UITextFieldViewModeAlways;

you can also refer to this trick also

like image 174
raaz Avatar answered Sep 22 '22 11:09

raaz


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];
like image 5
Ed Marty Avatar answered Sep 20 '22 11:09

Ed Marty