iphone - 删除NSURL路径的内容

标签 iphone objective-c ios uiimagepickercontroller assets

i使用以下代码保存从相机拍摄的照片

码:

- (IBAction)saveImage:(id)sender {
    UIImage *viewImage = imageView.image;  // was taken from Camera
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];  
    // Request to save the image to camera roll  
    [library writeImageToSavedPhotosAlbum:[viewImage CGImage] orientation:(ALAssetOrientation)[viewImage imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){  
        if (error) {  
            NSLog(@"error");  
        } else {  
            NSLog(@"url %@", assetURL); 
            self.imgUrl = assetURL;
        }  
    }];  
    [library release];
}

这是NSLOG的日志
assets-library://asset/asset.JPG?id=2A72A3FF-1662-4979-8DD7-0F5721C49F81&ext=JPG

现在,当我完成图像处理后,如何将其删除?

我试过了 :
 NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:[self.imgUrl absoluteString]  error:NULL];

但这没用
任何帮助都会很棒

先感谢您

最佳答案

如果您不打算将图像永久保存到用户的照片库,为什么要在最初将图像保存在那里?

您应该将图像保存到应用程序的沙箱文件夹,然后从那里删除它。

您不能从照片库中删除图像

关于iphone - 删除NSURL路径的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8666427/

相关文章:

objective-c - 为什么 gcc 或 clang 不能正确地@encode SIMD 矢量类型?

ios - 读取 API 响应中的数据 | iOS

ios - 有什么方法可以在不发送推送通知的情况下调用 saveCurrentTurnWithMatchData 吗?

iphone - 在动态 NSString 中间添加一个字符串

iphone - UIWebView 方法 loadHTMLString : and loadRequest 之间的区别

iphone - 从 xml 中提取特定元素

objective-c - 为什么 NSJSONSerialization 使用 NSData 而不是 NSString?

javascript onload 事件不会在 iPhone 上触发

ios - 设备重启后的 iBeacon 监控/测距

iphone - 应用程序中的多个 NSTimer