0

私のアプリでは、PersonPicker ビューを使用してアドレス ボックスから電子メール ID を取得しています。

電子メール ID を選択すると、電子メール ダイアログを開こうとします。しかし、それはただ開いてすぐに閉じます。

この問題を解決できません。

ここからコードを取得しました

私のコードは次のとおりです。

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{

    // Get the first and the last name. Actually, copy their values using the person object and the appropriate
    // properties into two string variables equivalently.
    // Watch out the ABRecordCopyValue method below. Also, notice that we cast to NSString *.
    NSString *firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    NSString *lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);

    // Compose the full name.
    NSString *fullName = @"";
    // Before adding the first and the last name in the fullName string make sure that these values are filled in.
    if (firstName != nil) {
        fullName = [fullName stringByAppendingString:firstName];
    }
    if (lastName != nil) {
        fullName = [fullName stringByAppendingString:@" "];
        fullName = [fullName stringByAppendingString:lastName];
    }


    // Get the multivalue e-mail property.
    CFTypeRef multivalue = ABRecordCopyValue(person, property);

    // Get the index of the selected e-mail. Remember that the e-mail multi-value property is being returned as an array.
    CFIndex index = ABMultiValueGetIndexForIdentifier(multivalue, identifier);

    // Copy the e-mail value into a string.
    email = (NSString *)ABMultiValueCopyValueAtIndex(multivalue, index);
    NSLog(@"%@",email);
    // Create a temp array in which we'll add all the desired values.
    NSMutableArray *tempArray = [[NSMutableArray alloc] init];
    [tempArray addObject:fullName];

    // Save the email into the tempArray array.
    [tempArray addObject:email];


    // Now add the tempArray into the contactsArray.
    [contactsArray addObject:tempArray];
    NSLog(@"%@",contactsArray);
    // Release the tempArray.
    [tempArray release];

    // Reload the table to display the new data.
    [table reloadData];

    // Dismiss the contacts view controller.
    [contacts dismissModalViewControllerAnimated:YES];
    [contacts release];


    MFMailComposeViewController* Apicker = [[MFMailComposeViewController alloc] init];
    if (Apicker != nil)
    {

        [Apicker setSubject:@""];
        NSString * someString = nil;
        someString=@"<a href=\"https://www.google.com\">Google</a>";
        [Apicker setMessageBody:someString isHTML:YES];

        NSArray *toRecipients = [NSArray arrayWithObjects:email, nil];
        [Apicker setToRecipients:toRecipients];

        Apicker.mailComposeDelegate = self;
        [self presentModalViewController:Apicker animated:YES];
        [Apicker release];

    }



    return NO;
}

モーダルビューを却下して提示する問題かもしれないと思います。

4

1 に答える 1

1

却下と現在の問題は、2つが重複していることです。-- それを却下し、あなたがしたようにそれを表示しますが、アニメーション化されているために問題が発生します。そこにアニメーションを付けたり、解雇後までプリセットを遅らせたりしないでください

于 2013-04-25T10:49:28.410 に答える