我想在我的应用程序中更改专辑名称。
if ([collection canPerformEditOperation:PHCollectionEditOperationRename] == YES)
{
//rename localizedTitle
}
如果那是"is",我想更改名称。
我的代码是:
PHFetchOptions *userAlbumsOptions = [PHFetchOptions new];
userAlbumsOptions.predicate = [NSPredicate predicateWithFormat:@"estimatedAssetCount > 0"];
PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:userAlbumsOptions];
[userAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop)
{
}];
最佳答案
-(void)changeAlbumtitle:(PHAssetCollection *)collection withTitle:(NSString *)title {
if (![collection canPerformEditOperation:PHCollectionEditOperationRename]) {
NSLog(@"can't PerformEditOperation");
return;
}
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCollectionChangeRequest *changeTitlerequest =[PHAssetCollectionChangeRequest changeRequestForAssetCollection:collection];
changeTitlerequest.title = title;
} completionHandler:^(BOOL success, NSError *error) {
NSLog(@"Finished editing collection. %@", (success ? @"Successfully." : error));
}];
}
在上面给出函数传递专辑对象(PHAssetCollection)和标题
编辑操作
关于objective-c - 如何编辑或重命名 PHAssetCollection LocalizedTitle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31239513/