我在應用程序文檔目錄的「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 –