UIPasteBoard不粘贴音频文件? [英] UIPasteBoard doesn't paste audio files?

查看:172
本文介绍了UIPasteBoard不粘贴音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中一个模块是,一个简单的列表TableView,显示音频文件列表。当用户选择任何音频文件时,操作表附带一个选项SMS。我需要通过短信发送特定的音频文件。请让我知道如何使用它。

I am developing an app in which one of the module is, A simple listing TableView which shows the list of audio file. When user selects any audio file an action sheet comes with one of the option SMS. I Need to send the particular audio file through SMS. Please let me know how to go with this.

如果无法做到这一点,请向我提供苹果文档,以便我作为证明我出示。

And if this is not possible, please provide me apple documentation so that it acts as a proof for me to show.

这是我试图粘贴音频文件...

This is what i have tried for pasting the audio file...

第一道:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *path = [[NSBundle mainBundle] pathForResource:@"audiofilename" ofType:@"caf"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[pasteboard setData:myData forPasteboardType:@"audiofile"];
NSString  *copyPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/audiofile.caf"];
NSURL *sndURL = [NSURL fileURLWithPath:copyPath];
[pasteboard setString:[NSString stringWithFormat:@"%@",sndURL]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"sms:12345678"]]];

第二种方式:

Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));

if([messageClass canSendText])
{
    messagepicker = [[MFMessageComposeViewController alloc] init];
    messagepicker.messageComposeDelegate = self;
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"290912044119" ofType:@"caf"];
    NSData *myData = [NSData dataWithContentsOfFile:path];
    [pasteboard setData:myData forPasteboardType:@"audiofile"];
    NSString  *copyPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/audiofile.caf"];
    NSURL *sndURL = [NSURL fileURLWithPath:copyPath];
    [messagepicker setBody:[NSString stringWithFormat:@"%@",sndURL]];
    [self presentModalViewController:messagepicker animated:YES];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

我知道这可以通过发布到服务器上并从中检索那里。但是,这不是要求。

任何帮助都将受到赞赏,如果不可能,请提供苹果文件。

Any help would be appreciated and if it's not possible then please provide with apple documents.

推荐答案


无法从当前sdk的消息中发送音频文件....您可以达到此要求将该声音文件上传到服务器,然后从消息中发送该URL。

It is not possible to send an audio file from message with current sdk....You can reach this requirement by upload that sound file to server and then send that url from message.

这篇关于UIPasteBoard不粘贴音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆