Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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
Cocoa touch 目标C-通过MFMailComposeViewController的附件未显示_Cocoa Touch_Email_Audio_Wav_Mfmailcomposeviewcontroller - Fatal编程技术网

Cocoa touch 目标C-通过MFMailComposeViewController的附件未显示

Cocoa touch 目标C-通过MFMailComposeViewController的附件未显示,cocoa-touch,email,audio,wav,mfmailcomposeviewcontroller,Cocoa Touch,Email,Audio,Wav,Mfmailcomposeviewcontroller,我正在尝试从iOS应用程序附加wav文件,但即使在合成邮件中可见,也无法传递该附件 相关代码如下: if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller se

我正在尝试从iOS应用程序附加wav文件,但即使在合成邮件中可见,也无法传递该附件

相关代码如下:

if ([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
    controller.mailComposeDelegate = self;
    [controller setSubject:NSLocalizedString(@"mailTopic", nil)];
    [controller setMessageBody:NSLocalizedString(@"mailBody", nil) isHTML:YES];
    NSString *wavPath = [self exportAssetAsWaveFormat:self.myRec.soundFilePath]; // CAF->Wav export

    if (wavPath != nil) {
        NSLog(@"wavPath: %@", wavPath);
        NSData *recData = [NSData dataWithContentsOfFile:wavPath];
        NSString *mime = [self giveMimeForPath:wavPath];
        [controller addAttachmentData:recData mimeType:mime fileName:@"MySound.wav"];
        [self presentModalViewController:controller animated:YES];
        [controller release];
    }
}


-(NSString *) giveMimeForPath:(NSString *)filePath {
    NSURL* fileUrl = [NSURL fileURLWithPath:filePath];
    NSURLRequest* fileUrlRequest = [[NSURLRequest alloc] initWithURL:fileUrl cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:.1];
    NSURLResponse* response = nil;

    [NSURLConnection sendSynchronousRequest:fileUrlRequest returningResponse:&response  error:nil];
    NSString* mimeType = [response MIMEType];
    NSLog(@"MIME: %@", mimeType);
    [fileUrlRequest release];

    return mimeType;
}
NSLog结果:

NSLog(@“wavPath:%@”,wavPath);->“wavPath:/var/mobile/Applications/71256DCA-9007-4697-957E-ae827fd97f/Documents/MySound.wav”

NSLog(@“MIME:%@”,mimeType);->“MIME:audio/wav”


文件路径设置为ok(参见NSLog数据),mime类型设置为“audio/wav”。。无法解决此问题。

可能目标是剥离该类型的附件?您是否尝试手动发送带有.wav的消息并查看其是否有效?我在发送给Zendesk时遇到了同样的问题。事实证明,它们删除了某些mimetype的附件。

错误在于,在我用它创建NSData时,wav文件并不是100%写入的。。杜乌


感谢各位的努力

我已经看到其他应用程序能够发送wav。好的,似乎这就是问题所在:NSData*recData=[NSData DATA WITH CONTENTS OFFILE:wavPath];测试数据对象的长度时,它始终为0,但不是零。。