Code Monkey home page Code Monkey logo

thpinviewcontroller's Introduction

THPinViewController

iOS 7 style PIN screen for iPhone and iPad that can be displayed modally whenever the user needs to authenticate, e.g. when accessing a specially protected part of your app.

Features

  • Has iPhone portrait and iPad portrait and landscape layouts
  • Supports variable PIN lengths
  • Buttons can show numbers and letters or only numbers
  • Background and tint colors as well as text and color of the prompt can be customized
  • Supports solid color and translucent/blurred background

Screenshots

Usage

THPinViewController *pinViewController = [[THPinViewController alloc] initWithDelegate:self];
pinViewController.promptTitle = @"Enter PIN";
pinViewController.promptColor = [UIColor darkTextColor];
pinViewController.view.tintColor = [UIColor darkTextColor];
pinViewController.hideLetters = YES;

// for a solid color background, use this:
pinViewController.backgroundColor = [UIColor whiteColor];

// for a translucent background, use this:
self.view.tag = THPinViewControllerContentViewTag;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
pinViewController.translucentBackground = YES;

[self presentViewController:pinViewController animated:YES completion:nil];

// mandatory delegate methods

- (NSUInteger)pinLengthForPinViewController:(THPinViewController *)pinViewController
{
    return 4;
}

- (BOOL)pinViewController:(THPinViewController *)pinViewController isPinValid:(NSString *)pin
{
    if ([pin isEqualToString:self.correctPin]) {
        return YES;
    } else {
        self.remainingPinEntries--;
        return NO;
    }
}

- (BOOL)userCanRetryInPinViewController:(THPinViewController *)pinViewController
{
    return (self.remainingPinEntries > 0);
}

// optional delegate methods

- (void)incorrectPinEnteredInPinViewController:(THPinViewController *)pinViewController {}
- (void)pinViewControllerWillDismissAfterPinEntryWasSuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerDidDismissAfterPinEntryWasSuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerWillDismissAfterPinEntryWasUnsuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerDidDismissAfterPinEntryWasUnsuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerWillDismissAfterPinEntryWasCancelled:(THPinViewController *)pinViewController {}
- (void)pinViewControllerDidDismissAfterPinEntryWasCancelled:(THPinViewController *)pinViewController {}

See the example project for more details.

Installation

###As a Git Submodule

git submodule add git://github.com/antiraum/THPinViewController.git <local path>
git submodule update

###Via CocoaPods

Add this line to your Podfile:

pod 'THPinViewController'

Compatibility

THPinViewController requires iOS 7.0 and above.

THPinViewController uses ARC. If you are using THPinViewController in your non-ARC project, you need to set the -fobjc-arc compiler flag for the THPinViewController source files.

License

Made available under the MIT License.

Collaboration

If you have any feature requests or bugfixes feel free to help out and send a pull request, or create a new issue.

thpinviewcontroller's People

Contributors

antiraum avatar badchoice avatar codetalks-new avatar loveagency avatar readmecritic avatar shimesaba9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thpinviewcontroller's Issues

Use with iPad UISplitViewController

Any suggestions on how to get the Passcode PIN View to show up from a UISplitViewController AppDelegate?

I am using below code but it never shows up.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window.rootViewController presentViewController:pinViewController animated:YES completion:nil];
...

Any suggestions are appreciated.

Localizaton files and cocoapods

After trying this with cocoapods, I realized that the localization tables are not included, I think it's because the spec.resources are missing, now cancel and delete button are not localizable

missing

Styling issue of Pad number buttons

Hi there,

Awesome VC, super easy to use. many thanks.

the only issue I've got right now is about Pad number buttons.
They look weird here
ios simulator screen shot 3 aug 2014 12 25 40 pm
does anyone have idea about why this may happen?

BSnapPinViewController *pinViewController = [[BSnapPinViewController alloc] initWithDelegate:self];
    pinViewController.promptTitle = @"Enter Pin";
    pinViewController.promptColor = [UIColor darkGrayColor];
    pinViewController.view.tintColor = [UIColor redColor];
    [pinViewController.view.layer setBorderColor:[[UIColor blueColor] CGColor]];
    [pinViewController.view.layer setBorderWidth:2.f];
    pinViewController.hideLetters = NO;


    // Solid background color
    pinViewController.backgroundColor = [UIColor darkGrayColor];
    pinViewController.disableCancel = YES;
//  // Transparent background color
    UIViewController *rootViewController = self.window.rootViewController;
//  rootViewController.view.tag = THPinViewControllerContentViewTag;
//  rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
//  pinViewController.translucentBackground = YES;

    [rootViewController presentViewController:pinViewController animated:NO completion:nil];

I was running this in iPhone 4-inch 7.0 simulator.

Cheers.

Use UIBlurEffect for blur

    self.blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    self.blurView.frame = self.parentVc.view.bounds;
    self.blurView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self.parentVc.view addSubview:self.blurView];

Set passcode the first time.

Is there a built in feature to set the password the first time? Any suggestions? From what I can see it currently validates once you passcode is known.

Thank you for a great control I do like it.

Apple Rejection due to 8.3 for using THPinViewController

That's "Apps that appear confusingly similar to an existing Apple product, interface, or advertising theme will be rejected". I also tried with hideLetters = NO, with the same result.
The same app, with THPinViewController has been approved many times before (as usual) so YMMV.
This is only as an advice to the other users of this very useful component. I'll try to see if I can tweak the UI a bit, in case will share my code back.
Thank you again for the code!

Optional Cancel Button

First off I would like to say thank you for this wonderful control, it does exactly what it says and does it well. The documentation in particular is impressive!

It would be nice if display of the Cancel button was optional, while the Delete button is useful in pretty much all scenarios, the Cancel button only makes sense when the view controller is presented modally. I know that you intend the view controller to be used modally so you likely don't see this as a problem.

Just to give you an idea of our use case, we embed the view controller in the very first screen that is shown after launching the app. Naturally in this case we have no where to go when Cancel is tapped, so displaying it could confuse users.

Cancel button always has white text

In a previous version, the text of the cancel button label would follow whatever color was set as promptColor, now it is always white, which is a problem when using a white background. Sample code:

THPinViewController *pinViewController = [[THPinViewController alloc] initWithDelegate:self];

pinViewController.disableCancel = NO;
pinViewController.promptTitle = title;
UIColor *darkBlueColor = [UIColor colorWithRed:0.012f green:0.071f blue:0.365f alpha:1.0f];
pinViewController.promptColor = darkBlueColor;
pinViewController.view.tintColor = darkBlueColor;
pinViewController.backgroundColor = [UIColor whiteColor];


[self presentViewController:pinViewController animated:animated completion:nil];

//cancel button not visible

No landscape support

Hello,

In the readme you mention this pod has support for iphone/ipad portrati and landscape orientation, but when I test on iPhone landscape top and bottom buttons of the pin-view are cut-off by the screen...

In other words, I don't think it is implemented... Is this correct?

Thnx

iOS 8, iPhone 5 layout

Hello,

really nice VC !!!

However, I have a bug on my iphone 5S with iOS 8. The inputCircle view is at the top of the screen !!!!

Moreover, it would be awesome if we could resize the view (I have a tabBar so the layout is not working correctly).

See you !

Dialpad

Thanks for THPinVC! Have you considered making it configurable to look and work like a phone dial pad?

Constraint crash

Not sure why this is crashing on iOS 8.0

2015-09-23 19:15:22.979 inSured[3517:293362] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
Expected a number or key from the metrics dictionary, but encountered something else
H:|[circle0]- (padding)-[circle1]- (padding)-[circle2]- (padding)-[circle3]|
^'

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.