Latest 1.0.1
Homepage https://github.com/HiTask/watchtower
License Apache License, Version 2.0 Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Platforms ios 7.0, requires ARC
Dependencies AFNetworking
Frameworks SystemConfiguration, MobileCoreServices, UIKit, QuickLook
Authors , , ,

What, why

This is a simple extension over QLPreviewController allowing to display remote files.

I created it primarily because QLPreviewItem states that previewItemURL must be a file-type URL (local files only).

This project is different from AMPPreviewController because this one uses AFNetworking 1.x and therefore is compatible with old cocoapods that use AFNetworking 1.x such as RestKit 0.20

Installation

CocoaPods

pod 'Watchtower'

Git Submodule

$ cd your_project
$ git submodule add [email protected]:zats/watchtower.git Vendor/Watchtower
$ cd Vendor/Watchtower
$ git submodule update --init --recursive
  • Add all the Watchtower folder to your project
  • Add QuickLook.framework to your targets
  • Optionally: if you don’t use AFNetworking in your project, make sure you’ve added files from the Vendor/AFNetworking folder

Usage

#import "AZAPreviewController.h"

That’s it, the rest is exactly like QLPreviewController, just specify remote URL instead of local in QLPreviewItem instance.

For more details see included project.

Notes

Class AZAPreviewItem simply provides default implementation of QLPreviewItem protocol making previewItemURL and previewItemTitle parameters writable.

If you want to be notified when remote item failed to load you have to implement AZAPreviewControllerDelegate corresponding protocol method:

- (void)AZA_previewController:(AZAPreviewController *)controller failedToLoadRemotePreviewItem:(id<QLPreviewItem>)previewItem withError:(NSError *)error
{
    NSString *alertTitle = [NSString stringWithFormat:@"Failed to load file %@", previewItem.previewItemURL];
    NSString *alertMessage = [error localizedDescription];
    [[[UIAlertView alloc] initWithTitle:alertTitle
                                message:alertMessage
                               delegate:nil
                      cancelButtonTitle:@"OK"
                      otherButtonTitles:nil] show];
}

TODOs

Currently if pan gesture wasn’t finished and next item didn’t finish loading it might stay in loading state forever, help much appreciated

Latest podspec

{
    "name": "Watchtower",
    "version": "1.0.1",
    "license": {
        "type": "Apache License, Version 2.0",
        "text": "    Licensed under the Apache License, Version 2.0 (the "License");n    you may not use this file except in compliance with the License.n    You may obtain a copy of the License atnn    http://www.apache.org/licenses/LICENSE-2.0nn    Unless required by applicable law or agreed to in writing, softwaren    distributed under the License is distributed on an "AS IS" BASIS,n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n    See the License for the specific language governing permissions andn    limitations under the License.n"
    },
    "homepage": "https://github.com/HiTask/watchtower",
    "authors": {
        "Sash Zats": "[email protected]",
        "Ilter Cengiz": "[email protected]",
        "Alejandro Martinez": "[email protected]",
        "Roman Roan": "[email protected]"
    },
    "summary": "Extension over QLPreviewController (QuickLook) allowing to display remote files. Uses AFNetworking 1.x",
    "source": {
        "git": "https://github.com/HiTask/watchtower.git",
        "tag": "1.0.1"
    },
    "source_files": "Classes",
    "frameworks": [
        "SystemConfiguration",
        "MobileCoreServices",
        "UIKit",
        "QuickLook"
    ],
    "dependencies": {
        "AFNetworking": [
            "~> 1.3.0"
        ]
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This