![](/img/trans.png)
[英]How to implement file browsing in iOS as it does not have built-in functionality in Xcode
[英]Browsing built-in sounds in iOS
是否有API(或只是一種hack)來用iOS設備上的內置聲音名稱填充TableView? 例如,查看Clock應用程序的警報部分:您可以從聲音名稱的TableView中為警報選擇聲音。
對於越獄電話,您可以訪問文件系統並獲取文件列表。
-(void)loadAudioFileList{
audioFileList = [[NSMutableArray alloc] init];
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL *directoryURL = [NSURL URLWithString:@"/System/Library/Audio/UISounds"];
NSArray *keys = [NSArray arrayWithObject:NSURLIsDirectoryKey];
NSDirectoryEnumerator *enumerator = [fileManager
enumeratorAtURL:directoryURL
includingPropertiesForKeys:keys
options:0
errorHandler:^(NSURL *url, NSError *error) {
// Handle the error.
// Return YES if the enumeration should continue after the error.
return YES;
}];
for (NSURL *url in enumerator) {
NSError *error;
NSNumber *isDirectory = nil;
if (! [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:&error]) {
// handle error
}
else if (! [isDirectory boolValue]) {
[audioFileList addObject:url];
}
}
}
來自庫的GitHub存儲庫。 iOSSystemSoundsLibrary
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.