Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 邮寄附件PDF从代码_Ios_Pdf_Attachment_Mailing - Fatal编程技术网

Ios 邮寄附件PDF从代码

Ios 邮寄附件PDF从代码,ios,pdf,attachment,mailing,Ios,Pdf,Attachment,Mailing,我又来了,有点麻烦 我想从我的应用程序发送一封附有pdf的电子邮件,因此我执行了以下操作: - (IBAction) sendMail:(UIButton *)sender { MFMailComposeViewController *controller1 = [[MFMailComposeViewController alloc] init]; controller1.mailComposeDelegate = self; if ([MFMailComposeVi

我又来了,有点麻烦

我想从我的应用程序发送一封附有pdf的电子邮件,因此我执行了以下操作:

- (IBAction) sendMail:(UIButton *)sender {

    MFMailComposeViewController *controller1 = [[MFMailComposeViewController alloc] init];

    controller1.mailComposeDelegate = self;
    if ([MFMailComposeViewController canSendMail]) {
        [controller1 setSubject:@"Brochure"];
        if (sender.tag == 101) {
            NSString *filePath = [[NSBundle mainBundle] pathForResource: @"web link" ofType: @"pdf"];  
            NSData *pdfData = [NSData dataWithContentsOfURL:filePath options: error:
            [controller1 setMessageBody:@"Brochure File" isHTML:YES];
            [controller1 addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"brochure.pdf"];
        }

        [self presentModalViewController:controller1 animated:YES];
    }
    [controller1 release];
}

没有问题,没有错误,什么都没有。当我试图从我的iPad发送邮件时,会有一个小图标,上面附有文件,但当我收到邮件时,它是空的,没有附件,什么都没有。有什么我遗漏的吗

这行代码绝对不应该编译:

NSData *pdfData = [NSData dataWithContentsOfURL:filePath options: error:
此外,您的文件路径可能是错误的。如果pdf正确加载为附件,则不应看到附件的图标。相反,您将看到pdf本身的大图像

如果将断点设置在NSData*pdfData=之后,并将鼠标悬停在pdfData上,则可能会显示该断点为零,数据为0字节