当按下调用的 viewManual时,我试图打开一个pdf
文档。UiButton
我已经添加了QuickLook
框架,目前有:
。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];
}
我已经从上一个线程中尝试了以下代码,但它不起作用,根本没有任何反应,而且我不确定我从这里去哪里。非常感谢任何帮助。