2013-04-25 71 views
0

在我的应用程序中,我使用PersonPicker视图从地址框中获取电子邮件ID。电子邮件对话框没有在iPhone SDK中打开

当我选择任何电子邮件ID时,我尝试打开电子邮件对话框。但它会立即打开&。

我无法解决这个问题。

我得到了代码Here

我的代码如下:

-(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; 
     [email protected]"<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; 
} 

我认为这可能是解雇&目前的模式来看待这个问题。

回答

1

你的问题与解雇和礼物是两者重叠。 - 解雇它,然后显示它有点像你做的,但是你遇到问题是因为东西是动画的。不要在那里动画或延迟预设,直到解雇后

+0

感谢您的回复!我做的和你完全一样,但当用户选择任何电子邮件ID时,我想显示邮件对话框。我怎样才能做到这一点? – AtWork 2013-04-25 10:53:04

+0

完全改写:D – 2013-04-25 10:57:02

+0

伟大的编码......!哇,我不能相信这就像是愚蠢的错误。再次感谢! – AtWork 2013-04-25 11:01:01