tags:

views:

201

answers:

2

I am making a table which has a row that looks like the "To:" line in the Apple Mail app. When you add new people to Mail from your address book, their name shows up in a rounded button.

I can create the button and use sizeToFit to make it fit snugly around the text - no problem.

However, once I do that, I can't figure out how wide the button has become. Is there an easy way to just stick a bunch of buttons in a cell and have it wrap as necessary automatically, or do I have to manually calculate the width and if it goes beyond the end of the screen, move to the next row?

Also, how do you get the width of a sizeToFit'ted button? button.frame returns null. Most perplexing.

+1  A: 

You might want to take a look at Joe Hewitt's three20 project, a collection of custom UI elements for the iPhone that were used in the development of the Facebook app.

The two classes you would be particularly interested are TTMessageController and TTPickerTextField.

From the project site:

TTMessageController emulates the message composer in Apple's Mail app. You can customize it to send any kind of message you want. Include your own set of message fields, or use the standard "To:" and "Subject:". Recipient names can be autocompleted from a data source that you provide.

TTPickerTextField is a type-ahead UITextField. As you type it searches a data source, and it adds bubbles into the flow of text when you choose a type-ahead option. I use this in TTMessageController for selecting the names of message recipients.

Martin Gordon
A: 

Is there a way to include many TTPickerTextField beside the default "To" and "Subject", like CC, and BCC ? Thanks

iphoneDev