0

MFmailComposer を使用してメール送信コードを実装しました...

それは問題ありませんが、問題は受信者の電子メールアドレスを選択することです。

アドレス帳の連絡先からメールアドレスを取得したい。

このヘルプを取得する方法

私はそれが与える連絡先のために ABPeoplePickerNavigationController デリゲートメソッドを実装しました

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                property:(ABPropertyID)property
                              identifier:(ABMultiValueIdentifier)identifier 
{
    if (property == kABPersonPhoneProperty) 
    {
        ABMultiValueRef emails = ABRecordCopyValue(person, property);
        CFStringRef phonenumberselected = ABMultiValueCopyValueAtIndex(emails, identifier);
        CFStringRef emailLabelSelected = ABMultiValueCopyLabelAtIndex(emails, identifier);
        CFStringRef emailLabelSelectedLocalized = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(emails, identifier));
        NSLog(@"\n EmailValueSelected = %@ \n EmailLabelSelected = %@ \n \EmailLabeSelectedlLocalized = %@", phonenumberselected, emailLabelSelected, emailLabelSelectedLocalized);

        recipientField.text = (NSString *)emails; //Crashes but accepts 'phonenumberselected'

       NSLog(@" emails###:%@...  phonenumberselected%@...  emailLabelSelected %@.... emailLabelSelectedLocalized %@")

    //emails###: ABMultiValueRef 0x80b7bc0 with 1 value(s) //**Log output Displyas like this**


        [ self dismissModalViewControllerAnimated:YES ];
        return NO;
    }   
    return YES;

}

How to write code to pick the selected EMail address from phone book

4

1 に答える 1

1

次のリンクは、連絡先から電子メールアドレスを取得して配列に追加する実装コードに使用されます。

参照リンク

于 2012-04-27T11:28:41.530 に答える