如何将应用程序中的铃声添加到iphone的铃声中?
我创建了一个包含铃声的应用程序,但如何将其添加到iphone的铃声中?您不能。苹果没有发布将铃声导出/写入操作系统的API 在应用程序中使用iTunes文件共享,并将铃声文件复制到应用程序的文档目录中如何将应用程序中的铃声添加到iphone的铃声中?,iphone,objective-c,cocoa-touch,Iphone,Objective C,Cocoa Touch,我创建了一个包含铃声的应用程序,但如何将其添加到iphone的铃声中?您不能。苹果没有发布将铃声导出/写入操作系统的API 在应用程序中使用iTunes文件共享,并将铃声文件复制到应用程序的文档目录中 在info.plist中将“应用程序支持iTunes文件共享”设置为“是” 在应用程序中的适当位置,使用以下代码复制文件: NSArray*path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,Y
NSArray*path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString*documentsDirectory=[paths objectAtIndex:0]
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyRingtone" ofType:@"m4r"];
NSData *mainBundleFile = [NSData dataWithContentsOfFile:filePath];
[[NSFileManager defaultManager] createFileAtPath:[documentsDirectory stringByAppendingPathComponent:@"MyRingtone.m4r"]
contents:mainBundleFile
attributes:nil];
NSString*文件路径=[[NSBundle mainBundle]路径资源:@“m4r”类型的“MyRingtone”;
NSData*mainBundleFile=[NSData dataWithContentsOfFile:filePath];
[[NSFileManager defaultManager]createFileAtPath:[文档目录stringByAppendingPathComponent:@“MyRingtone.m4r”]
目录:mainBundleFile
属性:无];
用户现在可以通过itunes访问铃声并将其添加到设备铃声中。首先感谢您。我在我的铃声添加项目中制作了一个按钮和一个功能,但我不明白它会做什么?你会在itunes中看到你的应用程序-你的设备-应用程序。和文件共享应用程序下的应用程序中。在那里,您可以单击应用程序并查看文件。您可以将其保存到本地pc。将其添加到“铃声”下,然后将其设置为铃声