Giter Club home page Giter Club logo

dmactivityinstagram's Introduction

DMActivityInstagram

iOS 6 style sharing for Instagram.

The easiest way to integrate DMActivityInstagram is via CocoaPods.

pod 'DMActivityInstagram', '0.0.2' 

If you're still living in the pre-CocoaPods stone age like a neanderthal, add the following files to your project

  • DMActivityInstagram.m
  • DMActivityInstagram.h
  • DMResizerViewController.h
  • DMResizerViewController.m
  • DMResizerViewController.xib
  • instagram.png
  • [email protected]
  • instagram~ipad.png
  • [email protected]

See DMAIDemoViewController in the example project for details of how to use this class. In short, though:

DMActivityInstagram *instagramActivity = [[DMActivityInstagram alloc] init];

NSString *shareText = @"CatPaint #catpaint";
NSURL *shareURL = [NSURL URLWithString:@"http://catpaint.info"];

NSArray *activityItems = @[self.imageView.image, shareText, shareURL];

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:@[instagramActivity]];
[self presentViewController:activityController animated:YES completion:nil];

It's a bit more complex on iPad, as you need to use a UIPopoverController, but the gist is the same. Again, see the example for usage.

Simulator Use

By default DMActivityInstagram will only appear in the UIActivityViewController's list of options if it detects Instagram is installed on the device (via canOpenURL:). This means it will NOT appear in the simulator, or on devices without Instagram installed.


These classes are ARC enabled, but you can -fobjc-arc them to use in non-ARC projects (not required if you're using CocoaPods).

If your iPad app creates square images, you need to set UIActivityInstagram's presentFromButton property. This should be the UIBarButtonItem you are presenting the UIActivityViewController from. This property is overwritten if the image is not square, and the UIDocumentInteractionController is shown from within the resizer view instead.

Pull requests welcomed. If you use this, and want to give something back, consider purchasing some or all of my apps (for instance CatPaint and Iconizer). Obviously, envelopes full of cash are accepted as well.

A side note about the implementation

Note: in the developer docs it says:

The default implementation of this method returns nil. Subclasses that provide additional UI using a view controller can override this method to return that view controller. If this method returns a valid object, the system presents the returned view controller for you, instead of calling the performActivity method. On iPad, your view controller is presented inside of a popover. On iPhone and iPod touch, your view controller is presented modally.

However experimental evidence shows otherwise. My iPad 2, running iOS 6 shows the returned DMResizerViewController as a modal view, not a popover. If anyone knows why this is, please advise.

dmactivityinstagram's People

Contributors

coryalder avatar ay8s avatar vtim avatar

Watchers

James Cloos avatar  avatar

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.