Quick Start Guide – Objective C


The following guide will get you up-and-running with the SEssentialsPullToAction component as quickly as possible. In this guide, we will introduce you to the key features of the Pull to Action control, including initial project setup and adding items. You can follow along with the related code sample: PullToActionGettingStarted.xcodeproj.

Creating a Pull to Action Control

Start up Xcode and create a new project (File / New / Single View Application).

Within your newly created project, add a reference to the ShinobiEssentials framework. Instructions for doing this can be found in the first section of the EssentialsUserGuide.

Firstly, we want to import in the correct headers to work with the control. At the top of the ViewController, add

#import <ShinobiEssentials/ShinobiEssentials.h>

In the viewDidLoad method, create a UIScrollview to attach ourselves to.

- (void)viewDidLoad
     [super viewDidLoad];

     //Create a scrollview to attach ourselves to
     UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:self.view.bounds];
     [self.view addSubview:scrollview];

     //Force the scrollview to allow scrolling when contentSize < bounds
     scrollview.alwaysBounceVertical = YES;

In this example, we set alwaysBounceVertical to make sure that we can pull down the UIScrollView, even when the content of the scrollview is fully on-screen.

Add the Pull to Action control, and attach it to the scroll view with the initWithScrollView: method.

//Create the Pull to Action control, and attach to the scroll view
SEssentialsPullToAction *pullToAction = [[SEssentialsPullToAction alloc] initWithScrollView:scrollview];
[scrollview addSubview:pullToAction];

With this, we can pull the UIScrollView down, and see the control at work.

Adding a Delegate

However the Pull to Action control does not disappear at this point. This is because it is still waiting to be told that the triggered action has been completed. To make this work, we need to add ourselves as the delegate, and implement the pullToActionTriggeredAction: method.

@interface ViewController () SEssentialsPullToActionDelegate

@implementation ViewController

- (void)viewDidLoad
    //Register for "actionTriggered" updates
    pullToAction.delegate = self;

-(void)pullToActionTriggeredAction:(SEssentialsPullToAction *)pullToAction
    //Put your custom action here

    //Tell the Pull to Action that we've finished our processing
    [pullToAction actionCompleted];


Now when you pull the UIScrollView down, it will execute your action before calling actionCompleted, informing the Pull to Action that it can disappear.

If you got stuck at any point, take a look at our related code sample: PullToActionGettingStarted.xcodeproj.