0

This is my code... i've tried every path-format I can think of to get this to work... Basically I want to show an image in a quick and easy picture viewer... The viewer shows (modally... brilliant) but then the image dosen't show inside of that... I can't think why, the image definitely exists, and yet it just shows as a black screen.

thanks for any help. :)

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    QLPreviewController *preview = [[QLPreviewController alloc] init];
    [preview setDataSource:self];
    [self presentModalViewController:preview animated:YES];
}


#pragma mark QLPreviewController delegate methods

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller {
    return 1;
}

- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {

    NSString *imagePath = [NSString stringWithFormat:@"%@",[[NSBundle mainBundle] bundleURL]];

    NSString *nextPath = [imagePath stringByAppendingPathComponent:imageName];

    NSURL *imageURL =  [NSURL URLWithString:nextPath];

    return imageURL;
}
Thomas Clayson
  • 29,657
  • 26
  • 147
  • 224
  • Note that unless you're using ARC, your instance of `QLPreviewController` in `viewDidLoad` will leak. – zekel Jun 21 '12 at 19:49

1 Answers1

1

NSURL *imageURL = [NSURL URLWithString:nextPath];

[NSURL fileURLWithPath:nextPath];

maedac
  • 26
  • 1
  • URLWithString only works for strings that are in the URL format (e.g. file:://localhost/... or http://wwww....) - a path is not in that format. – Daij-Djan Nov 11 '12 at 15:21