QLPreviewController - not displaying image from bundle?
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>) pre开发者_JAVA百科viewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {
NSString *imagePath = [NSString stringWithFormat:@"%@",[[NSBundle mainBundle] bundleURL]];
NSString *nextPath = [imagePath stringByAppendingPathComponent:imageName];
NSURL *imageURL = [NSURL URLWithString:nextPath];
return imageURL;
}
NSURL *imageURL = [NSURL URLWithString:nextPath];
[NSURL fileURLWithPath:nextPath];
精彩评论