我有,這是獲得使用該設備攝像頭拍攝的,圖像捕捉我保存的UIImage這樣後的UIImage,如何重新保存的UIImage相同的路徑
-(void)onCapture:(UIImage *)image {
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
NSFileManager *filemanager = [NSFileManager defaultManager];
NSString *pathToImage = [NSTemporaryDirectory() stringByAppendingPathComponent:@"my_photo_001.jpg"];
[filemanager createFileAtPath:pathToImage contents:imageData attributes:nil];
NSURL *imageFileUrl = [NSURL fileURLWithPath:pathToImage];
[self.delegate onDone:imageFileUrl];
}
的NSURL傳遞給後代理然後將這個NSURL傳遞給一個圖像編輯視圖控制器,我將UIImage以及NSURL傳遞給編輯視圖控制器,一旦有人編輯完成,我想用編輯的UIImage覆蓋存儲在NSURL中的UIImage所以我這樣做,
NSData *imageData = UIImageJPEGRepresentation(self.editImage.image, 1.0);
NSString *pathToImage = [pathOfCapturedImage absoluteString];
[imageData writeToFile:pathToImage atomically:YES];
NSURL *imageFileUrl = [NSURL URLWithString:pathToImage];
哪裏pathOfCapturedImage是我傳遞給我的編輯視圖控制器的變量。
但是,當我在保存後打開圖像打開未經編輯的圖像時,我在哪裏出錯了?
pl。檢查編輯的圖像是否正確存儲。 –
我該如何檢查? –
當你保存編輯的圖像,然後在控制檯中打印路徑...之後,複製該路徑 - >打開查找器 - >按下命令+ Shift + G並粘貼路徑,然後按回車你將移動到圖像位置 –