Obj*_*der 8 iphone objective-c ios photosframework phassetcollection
我正在使用Apples Photos Framework将PHAssetCollections加载到我的应用程序中.我总是得到智能收藏的英文名称.例如,我得到'收藏'而不是'收藏家'(瑞典语).我认为localizedTitle属性将返回模拟器或iPhone运行的语言.(在具有瑞典语和地区的iPhone上运行).
有人遇到过这种情况么?示例代码:
NSArray *collectionsFetchResults;
NSMutableArray *localizedTitles = [[NSMutableArray alloc] init];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
PHFetchResult *syncedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
subtype:PHAssetCollectionSubtypeAlbumSyncedAlbum options:nil];
PHFetchResult *userCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
// Add each PHFetchResult to the array
collectionsFetchResults = @[smartAlbums, userCollections, syncedAlbums];
for (int i = 0; i < collectionsFetchResults.count; i ++) {
PHFetchResult *fetchResult = collectionsFetchResults[i];
for (int x = 0; x < fetchResult.count; x ++) {
PHCollection *collection = fetchResult[x];
localizedTitles[x] = collection.localizedTitle;
NSLog(@"%@", collection.localizedTitle); //<= Always prints english names
}
}
Run Code Online (Sandbox Code Playgroud)
之所以collection.localizedTitle不返回任何其他语言,是因为您的应用程序只有一种本地化,即English. 这绝对是一个 Apple Bug,但这里有一个 hack,请按照以下步骤操作。
sv.lproj除了en.lproj您已有的文件夹之外,创建相关文件夹。更新
如果您想在添加空白文本后轻松添加更多语言,您可以通过选择项目添加其他答案中显示的内容,并在本地化部分添加语言并再次选择空白文件,因为我们不想本地化其他文件。
希望它有所帮助,如果有疑问,请在此处提问。
干杯。
| 归档时间: |
|
| 查看次数: |
910 次 |
| 最近记录: |