GithubHelp home page GithubHelp logo

honkmaster / ttopeninappactivity Goto Github PK

View Code? Open in Web Editor NEW
237.0 16.0 66.0 133 KB

UIActivity to display "Open In ..." and open UIDocumentInteractionController

License: MIT License

Objective-C 93.72% Ruby 6.28%

ttopeninappactivity's Introduction

TTOpenInAppActivity

TTOpenInAppActivity is a UIActivity subclass that provides an "Open In ..." action to a UIActivityViewController. TTOpenInAppActivity uses an UIDocumentInteractionController to present all Apps that can handle the document specified with by the activity items.

Used In

Requirements

  • As UIActivity is iOS 6 only, so is the subclass.
  • This project uses ARC. If you want to use it in a non ARC project, you must add the -fobjc-arc compiler flag to TTOpenInAppActivity.m in Target Settings > Build Phases > Compile Sources.

Installation

From CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like TTOpenInAppActivity in your projects. First, add the following line to your Podfile:

pod 'TTOpenInAppActivity'

If you want to use the latest features of TTOpenInAppActivity use normal external source dependencies.

pod 'TTOpenInAppActivity', :git => 'https://github.com/honkmaster/TTOpenInAppActivity.git'

Manually

  • Add the TTOpenInAppActivity subfolder to your project.
  • Add the required frameworks UIKit, ImageIO and MobileCoreServices to your project.

Usage.

NSURL *URL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"empty" ofType:@"pdf"]];
TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andRect:((UIButton *)sender).frame];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:@[openInAppActivity]];
    
activityViewController.popoverPresentationController.sourceView = self.view;
activityViewController.popoverPresentationController.sourceRect = ((UIButton *)sender).frame;
    
[self presentViewController:activityViewController animated:YES completion:NULL];

Contributers (Thank You!)

License

TTOpenInAppActivity is distributed under the terms and conditions of the MIT license.

ttopeninappactivity's People

Contributors

frankschlegel avatar gshaviv avatar hakanw avatar honkmaster avatar jesseditson avatar maxsz avatar paulz avatar t-unit avatar tsparber avatar voidref avatar vtourraine avatar waynehartman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ttopeninappactivity's Issues

WriteDown using TTOpenInAppActivity

Hi, Tobias!

I've already integrated TTOpenInAppActivity into my app WriteDown and it is available on the App Store. I'm very happy with it and I think my users would definitely love to have this feature included in the app.

Thank you very much for this awesome work!

Cheers,

Please add semantic version tags

Someone recently added TTOpenInAppActivity to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OS X and iOS Xcode projects and provides a central repository for iOS/OS X libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, TTOpenInAppActivity doesn't have any version tags. Someone added the previous HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didnโ€™t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

How can I load internet files?

I've implemented in my application a gallery with remote resources, and the one that I can't represent like images, gifs, videos.. I would like to open them with TTOpenInAppActivity. The problem is that I don't have the resources downloaded, I have their URLs. If I add the items to TTOpenInAppActivity in url format and for example the resource is a PDF I can't open it with external apps like Dropbox/Books...

I've tried to download it before and passing NSData to TTOpenInAppActivity, but I still have the same problem. Any suggestion about how can I get it?

Thanks

Publish 1.1 to Cocoapods

Looks like it's not up there, would love to switch back to a version number instead of a git ref!

Incompatibility with relative urls

AirDrop will fail when a relative url is sent to UIDocumentInteractionController. It can be solved with changing line 165 to this:

self.docController = [UIDocumentInteractionController interactionControllerWithURL:[fileURL absoluteURL]];

IOS 7 not working

In line 135
I think it should be "presentingViewController"
if ([self.superViewController presentingViewController]) {}

not "presentedViewController"
if ([self.superViewController presentedViewController]) {

Custom Provider

I'm trying to use a custom UIActivityItemProvider with your AppActivity, but for some reason the AppActivity is completely ignored if a custom provider is set. Basically I'm trying to pass only a file URL to your AppActivity while using a web URL for Facebook, Twitter, etc sharing. Thoughts on what could be wrong?

- (id)initWithPlaceholderString:(NSString*)placeholder
{
    self = [super initWithPlaceholderItem:placeholder];
    if (self) {   
    }
    return self;
}

- (id)item
{
    if ([self.activityType isEqualToString:@"TTOpenInAppActivity"])
        return [NSURL fileURLWithPath:@"file_path"];
    else
        return [NSURL URLWithString:@"file_path"];
    return nil;
}

@end

And then I initialize like this:

CustomActivityProvider *customItem = [[CustomActivityProvider alloc] initWithPlaceholderString:@""];

NSArray *activityItems = @[customItem];

TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andRect:CGRectMake(0, 0, 1, 1)];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:@[openInAppActivity]];

Using TTOpenInAppActivity for Calex

Hey,
I am very happy I have detected TTOpenInAppActivity. I have actually expected UIActivityViewController to offer this feature right away - so TTOpenInAppActivity is just what I need. Thanks for open sourcing it.

I will include it within the next Update of Calex.

iOS 8 GM Support

Hi,
Thanks again for this great control. I wanted to let you know about an issue with iOS 8. I'm using the iOS 8 GM build and TTOpenInAppActivity is not getting presented.

The Open In apps menu never displays and there are no errors in the console or in Xcode. Same behavior in my app and with the example app.

activityDidFinish when there are no apps to open file

I noticed that if a device doesn't have an app installed to open a document, activityDidFinish isn't called. I ended up adding the line [self activityDidFinish:YES] to the end of the openDocumentInteractionController method, right after showing the alert. I did this because I use the UIActivityViewController's completion handler to clean up the document after sharing it, so as not to accumulate disk space. There doesn't seem to be an issue with doing this, which is why I recommend you include it in an update.

Also, I love the iOS 7 icons! Awesome that this sharing system will be ready for it!

setCompletionWithItemsHandler called when tapping on "More" button in iPad popover controller

  1. Add a completion handler to UIActivityViewController (setCompletionWithItemsHandler:).

  2. Open the UIActivityViewController in a UIPopoverController.

    _popover = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
    // Store reference to superview (UIPopoverController) to allow dismissal
    openInAppActivity.superViewController = _popover;
    [_popover presentPopoverFromBarButtonItem:barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    
  3. Tap on "Open in ..." button.

  4. Tap on "More" button.

  5. Completion handler is incorrectly called. It is then never called again (even when dismissing the popover).

Example-project leaks instances of TTOpenInAppActivity

Reproduce:

  • Start the app in instruments with the Allocations-instrument
  • Tap on "Open In ..."
  • Choose the "Open in ..."-action
  • Close popover
  • Repeat and check the growing number of persistent instances of TTOpenInAppActivity

Using TTOpenInAppActivity

Hey, just wanted to let you know that I'm using TTOpenInAppActivity in an update for my app Trail Maker. The update isn't actually done yet, but it should be up in a couple weeks. Thank you for the work you put into this, it's great to be able to share with other applications!

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.