0

我需要一个称为电子邮件按钮的按钮来从选择器视图中从多个项目中进行一项选择,以通过电子邮件附加该选定项目。我被困在 IBAction 上。这是我的进步。

文件:

    -(void)pickerViewEmail:(UIPickerView *)pickerViewEmail didSelectRow:(NSInteger)row inComponent:(NSInteger)component

    {

        if ([[musicList objectAtIndex:row] isEqual:@"m1"])
        {

            MFMailComposeViewController *pickerEmail = [[MFMailComposeViewController alloc] init];
            pickerEmail.mailComposeDelegate = self;

            NSString *path = [[NSBundle mainBundle] pathForResource:@"m1" ofType:@"mp3"];
            NSData *myData = [NSData dataWithContentsOfFile:path];
            [pickerEmail addAttachmentData:myData mimeType:@"audio/mp3" fileName:@"m1"];

            [pickerEmail setSubject:@"Hello!"];

            // Set up recipients
            NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; 
            NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; 
            NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

            [pickerEmail setToRecipients:toRecipients];
            [pickerEmail setCcRecipients:ccRecipients]; 
            [pickerEmail setBccRecipients:bccRecipients];

            // Fill out the email body text
            NSString *emailBody = @"Hello";
            [pickerEmail setMessageBody:emailBody isHTML:NO];

            [self presentModalViewController:pickerEmail animated:YES];
            [pickerEmail release];

        }


 if ([[musicList objectAtIndex:row] isEqual:@"m2"])
        {

        }
 if ([[musicList objectAtIndex:row] isEqual:@"m3"])
        {

        }

IBA 动作:

-(IBAction)showEmail
{

    if ([MFMailComposeViewController canSendMail])
    {
                 [self pickerEmail]; I have a yellow error when i call this. What is the right solution?

    }

    else
    {

    }


}

iOS:如何使用pickerview方法在一个按钮中附加多个附件文件?

4

1 回答 1

0

我不明白您[self pickerEmail] 在代码中的调用 Higher,pickerEmail似乎是一个对象,类型MFMailComposeViewController,而不是方法。所以这个调用[self pickerEmail]在 Objective-C 中没有任何意义

于 2012-01-06T16:42:49.370 回答