2012-04-16 1 views
0

連絡先リストの連絡先に電子メールを送信しようとしています。私は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];の両方で試しました。

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

答えて

0

問題は、人々がモーダルピッカということでした解雇されようとしていたメールモーダルと衝突していた。人々のピッカーモーダルを即座に消してアニメーション化しないようにして解決しました。私はタブバーコントローラを使用していない

[self presentViewController:picker animated:YES completion:nil]; 
0

タブバーコントローラを使用していますか? そして、あなたはまた、あなたはブレークポイントを設定し、コントローラが正しく初期化されているかどうかを確認するために、POコントローラを行うことができます

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

を試してみてください(すなわち、それがnilではない)

+0

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

の代わり:

if(property == kABPersonEmailProperty){ [self dismissModalViewControllerAnimated:NO]; //etc... } 

0

は私が成功やっていました。ブレークポイントを設定すると、コントローラーが正しく初期化されたことがわかります。
関連する問題