Code Monkey home page Code Monkey logo

amppreviewcontroller's Introduction

AMPPreviewController

Version Platform

AMPPreviewController is a subclass of QLPreviewController that allows you to preview remote documents.

This class is designed to work with only one document at a time.

Also you can use a NSURL directly! Without the need of creating a QLPreviewItem conforming object. So the developer doesn't need to deal with dataSource methods, just instantiate and present ;)

Usage

With a remote URL

Just open a remote url:

NSURL *remoteURL = ...
AMPPreviewController *pc = [[AMPPreviewController alloc]
                            initWithRemoteFile:remoteURL];
[self presentViewController:pc animated:YES completion:nil];

You can also execute a block when the download starts or ends:

[pc setStartDownloadBlock:^(){
    ...
}];
[pc setFinishDownloadBlock:^(NSError *error){
    ...
}];

With a local path

You can also load a local file. This is the same as using the QLPreviewController but more simple if you just want to present a single file.

NSURL *localPath = ...
AMPPreviewController *pc = [[AMPPreviewController alloc] initWithFilePath:localPath];
[self presentViewController:pc animated:YES completion:nil];

With a preview item

MyItem *item = ...
AMPPreviewController *pc = [[AMPPreviewController alloc] initWithPreviewItem:item];
[self presentViewController:pc animated:YES completion:nil];

The item must conform to the QLPreviewItem protocol.

Additionally it can also conform to AMPPreviewItem wich adds the required remoteUrl method. It will be the same as using the initWithRemoteFile: method but with your own object.

Installation

AMPPreviewController is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "AMPPreviewController"

Author

Alejandro Martinez, [email protected]

License

AMPPreviewController is available under the MIT license. See the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.