Skip to content

Instantly share code, notes, and snippets.

@bradtheappguy
Created March 29, 2013 22:06
Show Gist options
  • Save bradtheappguy/5273997 to your computer and use it in GitHub Desktop.
Save bradtheappguy/5273997 to your computer and use it in GitHub Desktop.

R1 Effects SDK Quick Start (ios version)

The R1 Effects SDK allows user's to edit photos using filters, borders, cropping, stickers, and text effects.

Contents

Prerequisites

  • XCode 4.6 with iOS 6.0 SDK
  • Deployment target of 5.0 or greater

Quick Start

Setup

In order to use the SDK in an existing app, you must do the following:

  1. Project setup

Make sure you're running the latest version of Xcode and Apple's LLVM compiler.

  1. Download

Download the latest version of the Effects SDK from http://r1sdk.com/downloads

  1. Unzip

    Unzip the R1PhotoEffectsSDK.zip to a convient location

  2. Drag

    Drag the entire Unzipped folder into the project navigator of your XCode project. Ensure that Copy Items into destination group's folder (if needed) is selected Ensure that Create groups for any added folder is selected Ensure that the proper target for you app is selected.

  3. Link against libraries

    Check your target's "Link Binary With Libraries" build phase. Make sure your app is being linked against

R1PhotoEffectsSDK.a.

Link against the following libraries and frameworks:

  Foundation.framework
  UIKit.framework
  libR1PhotoEffectsSDK.a
  SystemConfiguration.framework
  OpenGLES.framework
  QuartzCore.framework
  AVFoundation.framework
  CoreMedia.framework
  CoreVideo.framework
  CoreGraphics.framework
  1. Add linker flags

    Update your target's (or project's) build settings to include the following "Other Linker Flags:"

     -ObjC -all_load
    
  2. Import headers

    Include the following line to make the library available to your code:

     #import "AFPhotoEditorController.h"
    

Basic Usage

First, enable the SDK in your Application Delegate's -application:didFinishLaunchingWithOptions: method. Use the key assigned to your app.

//Import the SDK
#import "R1EffectsSDK.h"

//Enable the sdk
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
{
	[[R1PhotoEffectsSDK sharedManager] enableWithKey:@"asf232jnj98asfadfdf"];
	//existing code...
}

To present the photo editor, create an instance of R1PhotoEffectsViewController, set it's delegate, assign a UIImage the user would like to edit and present it modaly. Implement the 2 required callback methods to handle the user canceling and finishing editing the image.

- (IBAction)buttonPressed
{
	//create the view controller
	R1PhotoEffectsViewController *photoEffectVC = [[R1PhotoEffectsSDK sharedManager] photoEffectsViewControllerWithCropSupport:YES];
	//Assign the delegate
            photoEffectVC.delegate = self;

	//present the view controller
	[self presentViewController:photoEffectVC animated:YES completion:nil]; 
}

- (void)photoEffectsViewController:(R1PhotoEffectsViewController *)controller didFinishWithImage:(UIImage *)image {
	//Do something with the resulting UIImage
            //For example:
            self.imageView.image = image;
            //Dismiss the editor
	[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)photoEditorCanceled:(AFPhotoEditorController *)editor
{
	 //Dismiss the editor
	[self dismissViewControllerAnimated:YES completion:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment