bottah / PAPasscode

Passcode view controller for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PAPasscode

PAPasscode is a standalone view controller for iOS to allow a user to set, enter or change a passcode. It's designed to mimic the behaviour in Settings.app while still allowing some customization. It includes a sample project which shows how it appears on iPhone and iPad devices.

screen1 screen2

Other features:

  • Supports both simple (PIN-style) and regular passcodes
  • Allows customization of title and prompts
  • Animates screens left and right
  • Requires ARC

Adding PAPasscode to your project

The simplest way to add PAPasscode to your project is to use CocoaPods. Simply add the following line to your Podfile:

	pod 'PAPasscode'

If you'd prefer to manually integrate it, simply copy PAPasscode/*.{m,h} and Assets/*.png into your project. Make sure you link with the QuartzCore framework.

Asking the user to set a passcode

First, implement the following delegate methods on your view controller:

- (void)PAPasscodeViewControllerDidCancel:(PAPasscodeViewController *)controller {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)PAPasscodeViewControllerDidSetPasscode:(PAPasscodeViewController *)controller {
	// Do stuff with controller.passcode...
    [self dismissViewControllerAnimated:YES completion:nil];
}

Then invoke the view controller as follows:

    PAPasscodeViewController *passcodeViewController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
    passcodeViewController.delegate = self;
    [self presentViewController:passcodeViewController animated:YES completion:nil];

The initForAction: allows you to specify the flow you'd like. Possible actions are:

  • PasscodeActionSet - set a new passcode
  • PasscodeActionEnter - enter an existing passcode
  • PasscodeActionChange - change an existing passcode

The included example project demonstrates the each of the flows.

License

Copyright (c) 2012, Denis Hennessy (Peer Assembly - http://peerassembly.com)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of Peer Assembly, Denis Hennessy nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PEER ASSEMBLY OR DENIS HENNESSY BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

Passcode view controller for iOS

License:Other