i am saving file in document directory and loading it in - (id)previewController:(QLPreviewController *)previewController previewItemAtIndex:(NSInteger)idx with [NSURL fileURLWithPath:self.path];
returned url is of right image. but QLPreviewController shows the last saved image.This problem is occuring only in iOS6.
here is the code:
-(void)loadAndSaveFile{
NSData *data = [NSData dataWithContentsOfURL:self.mainURL];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *arr=[self.urlString componentsSeparatedByString:@"."];
NSString *str=[arr lastObject];
self.pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"Preview.%@",str]];
[data writeToFile:self.pdfPath atomically:YES];
[self preview];
}
where preview is a method where i initialize QLPreviewController
and in datasource method previewItemAtIndex, i'm getting path like this
fileURL1=[NSURL fileURLWithPath:self.pdfPath]; NSLog(@"%@",fileURL1);
if ([QLPreviewController canPreviewItem:fileURL1]) {
NSLog(@"///////%@",fileURL1);
return fileURL1;
}