0

ピッカービューから複数のアイテムから1つの選択を行い、選択したアイテムを電子メールで添付するには、電子メールボタンと呼ばれる1つのボタンが必要です。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:@"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"])
        {

        }

IB アクション :

-(IBAction)showEmail
{

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

    }

    else
    {

    }


}

iOS : pickerview メソッドを使用して 1 つのボタンで複数の添付ファイルを添付する方法は?

4

1 に答える 1

0

私はあなたの呼び出しを理解していません[self pickerEmail] あなたのコードの上位は、メソッドではなく、pickerEmail型のオブジェクトのようです。MFMailComposeViewControllerしたがって、この呼び出し[self pickerEmail]は Objective-C では意味がありません

于 2012-01-06T16:42:49.370 に答える