LoginViewController.h/LoginViewController.m

LoginViewController.h

//
//  LoginViewController.h
//  ProtectedData
//
//  Created by  on 7/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "LockView.h"

@interface  LoginViewController : UIViewController <LockViewDelegate>

//  在屏幕上方显示字符串
@property (nonatomic, strong) UILabel *loginAppLabel;

@property (nonatomic, strong) LockView *lockView;

@end  

LoginViewController.m

//
//  LoginViewController.m
//  ProtectedData
//
//  Created by  on 7/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "LoginViewController.h"
#import "AppDefine.h"
#import "NSString+MD5HexDigest.h"

#import "PasswordListViewController.h"

@implementation LoginViewController

@synthesize loginAppLabel;
@synthesize lockView;

- (id)init
{
    self = [super initWithNibName:nil bundle:nil];

    return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    return [self init];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [self.navigationController setNavigationBarHidden:YES];
    
    [super viewDidLoad];
    
    [self.view setUserInteractionEnabled:YES];
    
    self.view.backgroundColor = [UIColor clearColor];
    
    self.lockView = [LockView instanceWithFrame:self.view.bounds WithDelegate:self];
    [self.view addSubview:self.lockView];
    
    self.loginAppLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0f, 20.0f, self.view.bounds.size.width - 40.0f, 46.0f)];
    self.loginAppLabel.backgroundColor = [UIColor clearColor];
    self.loginAppLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self.loginAppLabel setTextAlignment:UITextAlignmentCenter];
    [self.loginAppLabel setTextColor:[UIColor whiteColor]];
    [self.loginAppLabel setFont:[UIFont boldSystemFontOfSize:30.0f]];
    self.loginAppLabel.text = NSLocalizedString(@"LoginAppLabelText", nil);
    [self.view addSubview:self.loginAppLabel];
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - LockViewDelegate
- (void)beforeUnlocking
{
    
}

- (void)beganUnlock
{
    
}

- (void)unlocking
{
    
}

- (void)afterUnlock
{
    NSMutableString *unlockKey = [NSMutableString string];
    for (NSNumber *index in self.lockView.lastSelectedButtonsIndexArray) {
        [unlockKey appendFormat:@"%i", index.integerValue];
    }
    NSString *unlockKeyWithMd5 = [NSString stringWithString:[unlockKey md5HexDigest]];
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *userDefaultsUnlockKeyWithMd5 = [userDefaults stringForKey:USERDEFAULTAPPLOCKKEY];
    
    if ([unlockKeyWithMd5 isEqualToString:userDefaultsUnlockKeyWithMd5]) {
        PasswordListViewController *passwordListViewController = [[PasswordListViewController alloc] init];
        [self.navigationController pushViewController:passwordListViewController animated:YES];
    } else {
        [self.lockView resetButtons];
    }
}


@end

 

 

转载于:https://my.oschina.net/yongbin45/blog/69560

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值