我正在开发一个应用程序,其中一个模块是一个简单的列表 TableView,它显示了音频文件的列表。当用户选择任何音频文件时,操作表带有选项 SMS 之一。我需要通过 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"]]];
第二种方式:
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];
}
我知道这可以通过发布到服务器并从那里检索来实现。但是,这不是要求。
任何帮助将不胜感激,如果不可能,请提供苹果文件。