简体   繁体   English

在iPhone SDK中未打开电子邮件对话框

[英]E-mail dialog box is not open in iphone sdk

In my app, I am fetching the e-mail id from address box using PersonPicker view. 在我的应用程序中,我正在使用PersonPicker视图从地址框中获取电子邮件ID。

When i select any e-mail id, i try to open the e-mail dialog. 当我选择任何电子邮件ID时,我尝试打开电子邮件对话框。 But it will just open & close immediatly. 但是它将立即打开和关闭。

I can't able to solve this issue. 我无法解决此问题。

I got code from Here 我从这里得到代码

My code is as follow: 我的代码如下:

-(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;
}

I think it may be the issue of dismiss & present the modal view. 我认为这可能是解雇和提出模态观点的问题。

your problem with dismiss and present is that the two overlap. 您解雇和出席的问题是两者重叠。 -- dismiss it and THEN show it kinda like you did BUT you run into a problem because the stuff is animated. -将其关闭,然后再进行显示,就像您所做的那样,但是您遇到了问题,因为这些内容是动画。 dont animate there or delay the presetting till after the dismissal 不要在那里动画或将预设延迟到解雇之后

This is the link where you will get sample code which is provide by apple. 这是您将获得Apple提供的示例代码的链接。 https://developer.apple.com/library/ios/#samplecode/QuickContacts/Listings/Classes_QuickContactsViewController_h.html https://developer.apple.com/library/ios/#samplecode/QuickContacts/Listings/Classes_QuickContactsViewController_h.html

Click on this link and download sample code at top. 单击此链接,然后在顶部下载示例代码。 I hope it will help you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM