I trying to open a pdf
document when a UiButton
called viewManual is pressed. I have added the QuickLook
framework and currently have:
.h
#import <QuickLook/QuickLook.h>
@interface ObViewControllerUsingIObserve : UIViewController <QLPreviewControllerDataSource, QLPreviewControllerDelegate>
{
NSArray *documents;
}
- (IBAction)viewManual:(id)sender;
- (void)createList;
- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller;
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index;
.m
-(void) createList
{
documents = [NSArray arrayWithObjects:@"ObservationPDF.pdf", nil] ;
}
-(NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) previewcontroller
{
return [documents count];
}
- (id <QLPreviewItem>) previewController: (QLPreviewController *) previewController previewItemAtIndex: (NSInteger) index
{
return [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[documents objectAtIndex:0] ofType:nil]];
}
- (IBAction)viewManual:(id)sender {
[self createList];
QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
previewController.delegate = self;
previewController.currentPreviewItemIndex = [documents objectAtIndex:0];
[[self navigationController] presentViewController: previewController animated:YES completion:nil];
}
I have tried this following code from a previous thread but it does not work for, nothing happens at all, and I am not sure where I go from here. Any help much appreciated.