2012-01-06 21 views
0

我需要所谓的电子邮件按钮一个按钮,从多个项目做一个选择从选择器视图通过电子邮件并附上选择的项目。我被困在IBAction。这是我的进步。的iOS:如何在一个IBAction为从选择器视图选择多个项目检索发件人?

M档:

-(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:@"[email protected]"]; 
      NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
      NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"]; 

      [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"]) 
     { 

     } 

IBAction为:

-(IBAction)showEmail 
{ 

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

    } 

    else 
    { 

    } 


} 

iOS : How to attach a multiple attachment file in one button using pickerview method?

回答

0

我不明白您的通话[self pickerEmail] 高于你的代码,pickerEmail似乎是一个对象,而键入MFMailComposeViewController,而不是一种方法。因此呼叫[self pickerEmail]没有任何意义在Objective-C

+0

我的知识是有限的,直到这里,这就是为什么如果有人能因为IM通过学习实用的OOP的理解建议权SENCE。 – Amink 2012-01-07 16:46:17

相关问题