如何使用Three20的addRecipient方法?

问题描述:

我使用Three20TTMessageController来显示与包含收件人选取器的iPhone SMS应用程序类似的视图。如何使用Three20的addRecipient方法?

目前我能够自动搜索联系人和通过点击+按钮来浏览他们:

enter image description here

但是我有一个问题,以应用选定的接触到收件人字段。 TTMessageController实现了addRecipient方法,但我不确定如何使用它。

在扩展TTMessageController我有以下时选择的联系被触发方法我的控制器类,所以addRecipient就到这里找个地方:

- (BOOL)peoplePickerNavigationController: 
       (ABPeoplePickerNavigationController *)peoplePicker 
       shouldContinueAfterSelectingPerson:(ABRecordRef)person{ 
    //dismiss the contact selector 
    [self dismissModalViewControllerAnimated:NO]; 
    return NO; 
} 

任何想法如何添加收件人在方法?

将您的数据源中的单个项目添加到收件人字段。所以如果你的数据源有一个字符串数组(数组),你可以使用字符串来调用addRecipient:。该索引是您要在该字段中插入收件人的位置。

发布您的数据源实现,我会完全代码。

+0

http://pastebin.com/eS6EgShL这是我的TTMessageController实现。在代码中搜索@test,到目前为止,test已被添加到选择器字段中,但我希望添加选定的人员。我只希望只添加一个收件人,因此当用户点击添加时,应删除旧收件人 – 2011-04-02 15:29:22

+0

AddressBookDataSource是相关的类。我认为你需要重写TTMessageController的addRecipient并在TTPickerTextField上调用removeAllCells来清除它。 – ssteinberg 2011-04-02 15:43:44

+0

AddressBookDataSource实现是从这个问题的答案http://*.com/questions/5374684/how-to-use-three20-ttmessagecontroller – 2011-04-02 15:46:41