• Stars
    star
    521
  • Rank 84,952 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[DEPRECATED] Open source alternative to UIActivityViewController, highly customizable and compatible with iOS 5.0.

REActivityViewController

This project is no longer maintained, please use UIActivityViewController since it provides richer functionality in iOS 8.

===========

Open source alternative to UIActivityViewController, highly customizable and compatible with iOS 5.0. It allows to create custom activites with ease, you control their apperance and behavior and no longer restricted to single-color icons as with the default UIActivity.

REActivityViewController Screenshot

Out of the box activities include:

  • Facebook
  • Twitter
  • VKontakte
  • Tumblr (using XAuth)
  • Message
  • Mail
  • Open in Safari
  • Save to Pocket
  • Send to Instapaper
  • Save to Readability
  • Save to Diigo
  • Save to Kippt
  • Save to Album
  • Open in Maps
  • Print
  • Copy

All activites are compatible with iOS 5.0.

Requirements

  • Xcode 4.5 or higher
  • Apple LLVM compiler
  • iOS 5.0 or higher
  • ARC

Demo

First, you need to install dependencies using CocoaPods package manager in the demo project:

$ pod install

After that, build and run the REActivityViewControllerExample project in Xcode to see REActivityViewController in action.

If you don't have CocoaPods installed, check section "Installation" below.

Installation

The recommended approach for installating REActivityViewController is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation.

Install CocoaPods if not already available:

$ [sudo] gem install cocoapods
$ pod setup

Edit your Podfile and add REActivityViewController:

$ edit Podfile
platform :ios, '5.0'
pod 'REActivityViewController', '~> 1.6.7'

Install into your Xcode project:

$ pod install

Add #include "REActivityViewController.h" to the top of classes that will use it.

Manual installation

REActivityViewController needs to be linked with the following frameworks:

  • QuartzCore
  • AssetsLibrary
  • MessageUI
  • Twitter

The following framework must be added as optional (weak reference):

  • Social

Dependencies:

Example Usage

Configuring & presenting REActivityViewController

Presenting REActivityViewController is easy as 1-2-3. First, prepare activities that you're going to use. You can create custom activities right here in your code, no need to wrap your head around subclassing or providers as with UIActivityViewController. Once your activities are ready, prepare data source (userInfo) and present the view controller.

// Prepare activities
//
REFacebookActivity *facebookActivity = [[REFacebookActivity alloc] init];
RETwitterActivity *twitterActivity = [[RETwitterActivity alloc] init];
REVKActivity *vkActivity = [[REVKActivity alloc] initWithClientId:@"VK APP ID"];
RETumblrActivity *tumblrActivity = [[RETumblrActivity alloc] initWithConsumerKey:@"CONSUMER KEY" consumerSecret:@"CONSUMER SECRET"];
REMessageActivity *messageActivity = [[REMessageActivity alloc] init];
REMailActivity *mailActivity = [[REMailActivity alloc] init];
RESafariActivity *safariActivity = [[RESafariActivity alloc] init];
REPocketActivity *pocketActivity = [[REPocketActivity alloc] initWithConsumerKey:@"CONSUMER KEY"];
REInstapaperActivity *instapaperActivity = [[REInstapaperActivity alloc] init];
REReadabilityActivity *readabilityActivity = [[REReadabilityActivity alloc] initWithConsumerKey:@"CONSUMER KEY" consumerSecret:@"CONSUMER SECRET"];
REDiigoActivity *diigoActivity = [[REDiigoActivity alloc] initWithAPIKey:@"API KEY"];
REKipptActivity *kipptActivity = [[REKipptActivity alloc] init];
RESaveToCameraRollActivity *saveToCameraRollActivity = [[RESaveToCameraRollActivity alloc] init];
REMapsActivity *mapsActivity = [[REMapsActivity alloc] init];
REPrintActivity *printActivity = [[REPrintActivity alloc] init];
RECopyActivity *copyActivity = [[RECopyActivity alloc] init];

// Create some custom activity
//
REActivity *customActivity = [[REActivity alloc] initWithTitle:@"Custom"
                                                         image:[UIImage imageNamed:@"REActivityViewController.bundle/Icon_Custom"]
                                                   actionBlock:^(REActivity *activity, REActivityViewController *activityViewController) {
                                                       [activityViewController dismissViewControllerAnimated:YES completion:^{
                                                           NSLog(@"Info: %@", activityViewController.userInfo);
                                                       }];
                                                   }];

// Compile activities into an array, we will pass that array to
// REActivityViewController on the next step
//
NSArray *activities = @[facebookActivity, twitterActivity, vkActivity, tumblrActivity,
messageActivity, mailActivity, safariActivity, pocketActivity, instapaperActivity,
readabilityActivity, diigoActivity, kipptActivity, saveToCameraRollActivity, mapsActivity,
printActivity, copyActivity, customActivity];

// Create REActivityViewController controller and assign data source
//
REActivityViewController *activityViewController = [[REActivityViewController alloc] initWithViewController:self activities:activities];
activityViewController.userInfo = @{
    @"image": [UIImage imageNamed:@"Flower.jpg"],
    @"text": @"Hello world!",
    @"url": [NSURL URLWithString:@"https://github.com/romaonthego/REActivityViewController"],
    @"coordinate": @{@"latitude": @(37.751586275), @"longitude": @(-122.447721511)}
};

[activityViewController presentFromRootViewController];

You can also define per-activity userInfo dictionaries, for instance:

twitterActivity.userInfo = @{@"image": [UIImage imageNamed:@"Flower.jpg"],
                             @"text": @"Hello world! via @myapp"};

iPad specific

On iPad, you should use UIPopoverController to present REActivityViewController. _popoverController property of UIViewController is still a private API (sigh), so we'll need to pass it manually: activityViewController.presentingPopoverController = _activityPopoverController;

// Create REActivityViewController controller and assign data source
//
REActivityViewController *activityViewController = [[REActivityViewController alloc] initWithViewController:self.navigationController activities:activities];
    @"image": [UIImage imageNamed:@"Flower.jpg"],
    @"text": @"Hello world!",
    @"url": [NSURL URLWithString:@"https://github.com/romaonthego/REActivityViewController"],
    @"coordinate": @{@"latitude": @(37.751586275), @"longitude": @(-122.447721511)}
};

_activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
activityViewController.presentingPopoverController = _activityPopoverController;
[_activityPopoverController presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem
                                   permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Please note that our presenting view controller is the navigation controller, so we pass it in initWithViewController.

Creating custom activities

Creating custom activitis is super easy:

REActivity *customActivity = [[REActivity alloc] initWithTitle:@"Custom"
                                                         image:[UIImage imageNamed:@"REActivityViewController.bundle/Icon_Custom"]
                                                   actionBlock:^(REActivity *activity, REActivityViewController *activityViewController) {
                                                       [activityViewController dismissViewControllerAnimated:YES completion:^{
                                                           NSLog(@"Hey, there!");
                                                       }];
                                                   }];

If you want to subclass an activity, add this code into your init function, for example:

#import "MyCustomActivity.h"
#import "REActivityViewController.h"

@implementation MyCustomActivity

- (id)init
{
    return [super initWithTitle:@"My Activity"
                          image:[UIImage imageNamed:@"My_Icon"]
                    actionBlock:^(REActivity *activity, REActivityViewController *activityViewController) {
                        // Your code goes here
                    }];
}

@end

Customization

All views are exposed for your customization. Say, you want to change controller background and customize cancel button, here is how you would do it:

REActivityViewController *activityViewController = [[REActivityViewController alloc] initWithViewController:self activities:activities];

activityViewController.activityView.backgroundImageView.image = [UIImage imageNamed:@"My_Cool_Background"];
[activityViewController.activityView.cancelButton setBackgroundImage:[UIImage imageNamed:@"My_Cool_Button"] forState:UIControlStateNormal];

Your custom activity icons must be 118x118 pixels and should include gloss, rounded corners and shadows. Easy way to make them:

  1. Open your 114x114 icon with rounded corners in Photoshop (you can convert your square icon using template from http://appicontemplate.com).
  2. Adjust canvas size to be 118x118, so the top part of the icon touches top part of the canvas.
  3. Add drop shadow to the icon layer: angle 90, opacity 40%, distance 2px, size 2px.

Contact

Roman Efimov

License

REActivityViewController is available under the MIT license.

Copyright © 2013 Roman Efimov.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

RESideMenu

iOS 7/8 style side menu with parallax effect.
Objective-C
7,101
star
2

REFrostedViewController

iOS 7/8 style blurred view controller that appears on top of your view controller.
Objective-C
2,965
star
3

RETableViewManager

Powerful data driven content manager for UITableView.
Objective-C
2,477
star
4

REMenu

Dropdown menu inspired by Vine.
Objective-C
2,196
star
5

REComposeViewController

[DEPRECATED] Sharing composers for the rest of us.
Objective-C
649
star
6

RETrimControl

iOS audio trim control, similar to the one seen in default iPhone Voice Memos app.
Objective-C
288
star
7

REFormattedNumberField

UITextField subclass that allows numeric input in a predefined format.
Objective-C
201
star
8

REMarkerClusterer

REMarkerClusterer creates and manages per-zoom-level clusters for large amounts of markers.
Objective-C
195
star
9

REPhotoCollectionController

REPhotoCollectionController is a photo thumbnail viewer for the iOS that groups photos by date.
Objective-C
109
star
10

RECurtainViewController

A custom curtain-style transition for UIViewControllers.
Objective-C
81
star
11

RESwitch

Open source alternative to UISwitch, customizable via UIAppearance protocol.
Objective-C
78
star
12

REPagedScrollView

Paged UIScrollView with an embedded UIPageControl.
Objective-C
68
star
13

REValidation

Simple Objective-C object validation.
Objective-C
65
star
14

AFXAuthClient

AFNetworking Extension for XAuth Authentication.
Objective-C
58
star
15

REImageSprite

[DEPRECATED] CSS-like image sprites for iOS apps.
Objective-C
39
star
16

REDebugClient

Advanced remote Xcode logging in Terminal app.
Objective-C
37
star
17

paypal-recurring-payments

PHP PayPal Recurring Payments with Billing Agreement (could be used with cron jobs)
PHP
36
star
18

REUIKitAdditions

Category additions to UIKit.
Objective-C
28
star
19

restkit-generate

A model generator for RestKit (http://github.com/RestKit/RestKit).
Ruby
27
star
20

MapViewExample

MapView iPhone app
Objective-C
25
star
21

TableViewDataManager

Powerful data driven content manager for UITableView written in Swift.
Swift
21
star
22

paypal-express-checkout

PHP PayPal express checkout easy integration
PHP
16
star
23

iPodLyricsExample

iPodLyrics, banned from the app store
Objective-C
7
star
24

dotfiles

My dotfiles
Shell
1
star