連絡先リストの連絡先に電子メールを送信しようとしています。を使用していABPeoplePickerNavigationController
ます。ユーザーが連絡先の電子メールを選択すると、次のことが起こります。
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
if(property == kABPersonEmailProperty){
[self dismissModalViewControllerAnimated:YES];
ABMultiValueRef emails = ABRecordCopyValue(person, property);
int index = ABMultiValueGetIndexForIdentifier(emails, identifier);
NSString *emailValueSelected = (__bridge NSString*)ABMultiValueCopyValueAtIndex(emails, index);
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"the subject"];
[controller setMessageBody:@"Hello there" isHTML:NO];
[controller setToRecipients:[[NSArray alloc] initWithObjects:emailValueSelected, nil]];
if (controller){
[self presentModalViewController:controller animated:YES];
}
return NO;
}
return YES;
}
変数にはemailValueSelected
正しい email 値があり、すべてのコードは問題なく実行されているようです (if(controller){...}
ステートメントの本文も)。
問題は、何も起こらず、電子メール コントローラーが表示されないことです。[self presentViewController:controller animated:YES completion:nil]
との両方を試しました[self presentModalViewController:controller animated:YES];
。
アプリケーションの別の部分でまったく同じコードを使用して電子メールを送信すると、正しく機能するため、ピープルピッカーと関係があると推測しています。