i got a uicollectionsview
when i select i image from there i want it to show in the Quicklook i think i got it to select the file prober but showing it crashes the app with this message :
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL length]: unrecognized selector sent to instance 0xb7be9c0'
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didselect");
QLPreviewController * preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.currentPreviewItemIndex = indexPath.row;
[self presentViewController:preview animated:YES completion:Nil];
}
#pragma mark -
#pragma mark QLPreviewControllerDelegate methods
- (BOOL)previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id <QLPreviewItem>)item {
return YES;
}
#pragma mark -
#pragma mark QLPreviewControllerDataSource methods
- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller {
return [photoURLsLargeImage count];
}
this is where my problem is, i think:
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {
NSString *entry = [photoURLsLargeImage objectAtIndex:index];
return [NSURL fileURLWithPath:entry];
}
photoURLsLargeImage is a nsmutablearray with at least 17 objects fetched from flickr
Add datasource
preview.dataSource = self;
And add the delegate method.
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
Your problem solved.