我在应用程序文档目录的“PhotoAlbum”文件夹中有24个图像。如何删除“PhotoAlbum”中的选定图像?我如何传递对象索引?在应用程序文档目录中删除图像
我有这样的事情:
- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/PhotoAlbum"];
NSString *fullPath = [dataPath stringByAppendingPathComponent:[self.photos objectAtIndex:index]];
NSData *pngData = [NSData dataWithContentsOfFile:fullPath];
UIImage *image = [UIImage imageWithData:pngData];
MWPhoto *photo = [[MWPhoto alloc] initWithImage:image];
return photo;
}
ohk..create你的形象与独特的名字说myImage1,myImage2,myImage3,......等,并将它们保存在您的文件夹。这里1,2,3,...都是唯一的索引。现在只需激发选定索引图像的删除选项。希望你得到我 –
看到这个快速教程:https://iosdevcenters.blogspot.com/2016/04/save-and-get-image-from-document.html –