将图像保存到文档目录不再适用于iOS8

将图像保存到文档目录不再适用于iOS8,ios8,nsdocumentdirectory,Ios8,Nsdocumentdirectory,在iOS8中,将图像保存到documents目录似乎不再有效。我听说有。但我似乎仍然无法让我的代码正常工作。我将一个图像保存到documents目录,然后检索它以供以后使用。这是我在文档目录中保存图像的代码 -(void) simpleCam:(SimpleCam *)simpleCam didFinishWithImage:(UIImage *)image { if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerC

在iOS8中,将图像保存到documents目录似乎不再有效。我听说有。但我似乎仍然无法让我的代码正常工作。我将一个图像保存到documents目录,然后检索它以供以后使用。这是我在文档目录中保存图像的代码

-(void) simpleCam:(SimpleCam *)simpleCam didFinishWithImage:(UIImage *)image {

if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    //choose Photo

}else{

    if (image) {

        //save the image to photos library
        UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

        NSData *imageData = UIImageJPEGRepresentation(image,1);

        // Get image path in user's folder and store file with name image_CurrentTimestamp.jpg (see documentsPathForFileName below)
        NSString *imagePath = [self documentsPathForFileName:[NSString stringWithFormat:@"image_%f.jpg", [NSDate timeIntervalSinceReferenceDate]]];


        // Write image data to user's folder
        [imageData writeToFile:imagePath atomically:YES];

        // Store path in NSUserDefaults
        [[NSUserDefaults standardUserDefaults] setObject:imagePath forKey:[NSString stringWithFormat:@"%@%@",kImageDataKey,self.accessToken]];

        // Sync user defaults
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}
以及my
DocumentsAthForFileName
方法

- (NSString *)documentsPathForFileName:(NSString *)name {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];

return [documentsPath stringByAppendingPathComponent:name];
}
映像路径返回空,但在iOS7中工作正常