Man*_*epa 6 iphone sms uipasteboard
我正在开发一个应用程序,其中一个模块是,一个简单的列表TableView,显示音频文件列表.当用户选择任何音频文件时,操作表附带一个选项SMS.我需要通过短信发送特定的音频文件.请让我知道如何使用它.
如果这是不可能的,请提供苹果文档,以便它作为我展示的证据.
这是我试图粘贴音频文件...
第一种方式:
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"]]];
Run Code Online (Sandbox Code Playgroud)
第二种方式:
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];
}
Run Code Online (Sandbox Code Playgroud)
我知道这可以通过发布到服务器并从那里检索来实现.但是,这不是要求.
任何帮助将不胜感激,如果不可能,请提供苹果文件.
归档时间: |
|
查看次数: |
843 次 |
最近记录: |