0

連絡先リストの連絡先に電子メールを送信しようとしています。を使用してい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];

アプリケーションの別の部分でまったく同じコードを使用して電子メールを送信すると、正しく機能するため、ピープルピッカーと関係があると推測しています。

4

3 に答える 3

0

タブバーコントローラーを使用していますか? 次に、試してみてください

[self.tabBarController presentModalViewController:controller animated:YES];

また、ブレークポイントを設定して po コントローラーを実行し、コントローラーが正しく初期化されているか (つまり、nil でないか) を確認することもできます。

于 2012-04-17T00:30:14.650 に答える
0

私は成功しました:

[peoplePicker presentViewController:picker animated:YES completion:nil];

それ以外の:

[self presentViewController:picker animated:YES completion:nil];
于 2012-09-17T19:33:17.143 に答える
0

問題は、却下されたピープル ピッカー モーダルが、表示されようとしていた電子メール モーダルと衝突していたことです。People Pickerモーダルを即座に非表示にし、アニメーション化しないことで解決しました。

if(property == kABPersonEmailProperty){
    [self dismissModalViewControllerAnimated:NO];
    //etc...
}
于 2012-04-17T13:35:03.937 に答える