我正在开发iOS应用程序。我是iOS中文件操作的新手。我想通过电子邮件发送,分享和打印每个pdf文件。那些pdf文件被捆绑在一起。
在我的View Controller中,我创建了3个按钮:
我应该怎么做才能实现这些行动?
答案 0 :(得分: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];
}
}
}