0
ピッカービュー内に複数のファイルを添付しています。ユーザーがそのピッカーの表示項目を選択すると、電子メールボタンをクリックして選択したファイルを添付できます。ピッカービューではどうすればいいですか?iOS:pickerviewメソッドを使用して1つのボタンに複数の添付ファイルを添付するにはどうすればよいですか?
ここは私のサンプルコードです。
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];
}
メールボタン:どのように私はここからスタートします。ユーザーがpickerviewsの行を選択した場合
-(IBAction)showEmail
{
if ([MFMailComposeViewController canSendMail])
{
[self pickerEmail]; I have a yellow error when i call this. What is the right solution?
}
else
{
}
}
私はいくつかのコードの修正を行っています。私はおそらく送信者を取得する方法のサンプルが必要です。私は本当に初心者です。コード修正でemailMeという変数があります。 – Amink
あなたは2つのpickerViewデリゲートメソッドが必要です:再生用とメール用のどちらですか? – Amink
ユーザーがピッカービューの値を変更すると、クラス変数の値が変更されます。ユーザーがボタンを押すと、showEmailが呼び出され、クラス変数の値が使用されます。私は自分の答えを更新しました - いくつかのサンプルコードを追加しました。これは、1つのビューに3つのスライダがある場合のコードです。各スライダーには独自のデリゲートがあります。 – wzbozon