带有K PassCode Lock的iOS密码

时间:2014-03-06 15:09:50

标签: ios passwords appdelegate

我在我的应用程序中使用KKPassCodeLock类并且我已经完成了设置,我唯一没有得到的是一旦设置了密码以启动应用程序。我搜索了很多,我发现有些人有同样的问题,但找不到解决方案,也不知道会发生什么。我的应用程序以带有5个选项卡的tabBarController开始。

根据示例类AppDelegate.h的示例应配置为:

AppDelegate.h

#import <UIKit/UIKit.h>
#import "KKPasscodeLock.h"
#import "KKPasscodeViewController.h"
#import "SettingsViewController.h"
#import "RootViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate,KKPasscodeViewControllerDelegate>

// contraseña de la aplicación
@property (nonatomic) IBOutlet UINavigationController *navigationController;
@property (strong, nonatomic) UIWindow *window;

@end

AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate

// contraseña de la aplicación
@synthesize navigationController = _navigationController;
@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// contraseña de la aplicación

[[KKPasscodeLock sharedLock] setDefaultSettings];
[KKPasscodeLock sharedLock].eraseOption = YES;

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];

RootViewController* vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

_navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
[self.window setRootViewController:_navigationController];
[self.window makeKeyAndVisible];

// contraseña de la aplicación
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) {
    KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil];
    vc.mode = KKPasscodeModeEnter;
    vc.delegate = self;

    dispatch_async(dispatch_get_main_queue(),^ {
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            nav.modalPresentationStyle = UIModalPresentationFormSheet;
            nav.navigationBar.barStyle = UIBarStyleBlack;
            nav.navigationBar.opaque = NO;
        } else {
            nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor;
            nav.navigationBar.translucent = _navigationController.navigationBar.translucent;
            nav.navigationBar.opaque = _navigationController.navigationBar.opaque;
            nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle;
        }

        [_navigationController presentModalViewController:nav animated:NO];
    });
}
}

// contraseña de la aplicación
- (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Has ingresado incorrectamente la contraseña muchas veces. Todas las notas de tu base de datos han sido eliminadas." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

[alert show];
}

// contraseña de la aplicación
- (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Has ingresado incorrectamente la contraseña muchas veces." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}

@end

在示例应用程序中必须打开一个名为RootViewController的xib,但在我的情况下不应该像我一样,让它以空白屏幕开始,即xib。

我如何配置它来启动密码请求和我的tabBarController而不是那个xib?

非常感谢!

0 个答案:

没有答案