我创建了一个应用程序,其中包括一个铃声,但如何将其添加到iPhone的铃声中?
我创建了一个应用程序,其中包括一个铃声,但如何将其添加到iPhone的铃声中?
在你的应用中使用iTunes文件共享并将铃声文件复制到应用的文档目录中。
在你的info.plist中将“Application supports iTunes file sharing”设置为YES
在适当的地方使用以下代码来复制文件:
NSArray *paths = 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];
现在用户可以通过iTunes访问铃声并将其添加到他们设备的铃声中。
不行。苹果没有发布导出/写铃声到操作系统的API。