連絡先リストの連絡先に電子メールを送信しようとしています。私はABPeoplePickerNavigationController
を使用しています。ユーザーが連絡先のメールを選択すると、次のことが起こる:連絡先リストから電子メールを選択した後、MFMailComposeViewControllerが開かない
- (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
変数は、正しいメール値を持っており、すべてのコードは、何らかの問題(if(controller){...}
文のも、ボディ)なしで実行しているようです。
問題は何も起こらず、電子メールコントローラは表示されません。私は[self presentViewController:controller animated:YES completion:nil]
と[self presentModalViewController:controller animated:YES];
の両方で試しました。
私のアプリケーションの別の部分でまったく同じコードを使用して電子メールを送信すると、正しく動作するため、人選機と何か関係があると推測しています。
:
の代わり:
–