gpt4 book ai didi

iphone - UIPasteBoard 不粘贴音频文件?

转载 作者:行者123 更新时间:2023-12-03 18:47:16 26 4
gpt4 key购买 nike

我正在开发一个应用程序,其中一个模块是一个简单的列表 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"]]];

第二种方式:

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];
}

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

任何帮助将不胜感激,如果不可能,请提供苹果文档。

最佳答案

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.

关于iphone - UIPasteBoard 不粘贴音频文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12971160/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com