iOSアプリケーションを開発しています。iOSでのファイル操作の初心者です。各PDFファイルをメールで送信、共有、印刷したい。これらのPDFファイルはバンドルされていた。
View Controllerで、3つのボタンを作成しました:
- Eメール
- iBooks
- 印刷
これらのアクションを達成するにはどうすればよいですか?
回答:
回答№1は0これはあなたにとって電子メールの助けになるかもしれません:
まず、インポート MessageUI.framework
あなたのアプリケーションで。
また、デバイスまたはシミュレーターは、いずれかの電子メールアカウントで構成する必要があります。
次に、電子メールボタンのクリックイベントは次のようになります。
-(void)ClickOnEmailUs
{
MFMailComposeViewController *picker;
picker = [[MFMailComposeViewController alloc] init];
if(picker)
{
if ([MFMailComposeViewController canSendMail])
{
picker.mailComposeDelegate = self;
[picker setToRecipients:receipientsArrayOfStrings];
[picker setSubject:@"Your Subject"];
[picker setMessageBody:@"E-Mail Body" isHTML:YES];
[picker addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"file.pdf"]; // for adding attachment to the mail
[self.navigationController presentModalViewController:picker animated:YES];
}
else
{
UIAlertView *noEmailAccountMsg = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Please configure your email account." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[noEmailAccountMsg show];
}
}
}