• iOS QLPreviewController(Quick Look)快速浏览jpg,PDF,world等


    #import <QuickLook/QuickLook.h>

    @interface ViewController ()<QLPreviewControllerDataSource,QLPreviewControllerDelegate>

    @property (nonatomic, strong)QLPreviewController *QLPreVC;

    - (void)viewDidLoad

    {

        [super viewDidLoad];

    _QLPreVC=[QLPreviewController new];

        _QLPreVC.dataSource=self;

        _QLPreVC.delegate=self;

     }

     //代理方法

    - (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller

    {

        return 3;//显示页数

    }

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

    {

    //方法一:打开本地存储文件

        NSURL *targetURL = [NSURL URLWithString:_url];

        NSString *docPath = [self documentsDirectoryPath];

        // Combine the filename and the path to the documents dir into the full path

        NSString *pathToDownloadTo = [NSString stringWithFormat:@"%@/%@", docPath, [targetURL lastPathComponent]];

        

        NSLog(@"-========--%@---",pathToDownloadTo);

        BOOL hasPDF=NO;

        

        NSFileManager *fileManager = [NSFileManager defaultManager];

        hasPDF = [fileManager fileExistsAtPath:pathToDownloadTo];

       

        targetURL = [NSURL fileURLWithPath:pathToDownloadTo];

           

    //方法二:打开url链接

    //     NSURL *targetURL = [NSURL URLWithString:@"file:///Users/mac/Downloads/doc-previewer/Core%20J2ME%20Technology.pdf"];

        

        return targetURL;

    }

    //最后只要在触发事件里面push即可:

    - (void)nextpage_showFiles {

        [self.navigationController pushViewController:_QLPreVC animated:YES];

       }

  • 相关阅读:
    [hdu4035]maze
    [codeforce][148d]
    [bzoj3507]通配符匹配
    [BZOJ4831]
    子串
    【洛谷1373】小a和uim之大逃离
    【JZOJ6303】演员
    [jzoj6296]选票
    字符串哈希
    [ABC137d&e]RE
  • 原文地址:https://www.cnblogs.com/niexiaobo/p/4642472.html
Copyright © 2020-2023  润新知