2014-10-29 69 views
1

接連查看我打得四處TouchID了一下,我有以下問題:加載成功TouchID登錄

成功TouchID登錄後,我該如何提出一個新的視圖控制器?

在viewController.m的代碼是:

#import "ViewController.h" 
@import LocalAuthentication; 
#import "SVProgressHUD.h" 
@interface ViewController() 

@end 

@implementation ViewController 



- (void)viewDidLoad { 
    [super viewDidLoad]; 

     LAContext *context = [[LAContext alloc] init]; 
     NSError *error; 

     // check if the policy can be evaluated 
     if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) 
     { 
      NSLog(@"error:%@", error); 
      NSString *msg = [NSString stringWithFormat:@"Can't evaluate policy! %@", error.localizedDescription]; 
      [SVProgressHUD showErrorWithStatus:msg]; 
      return; 
     } 

     // evaluate 
     [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics 
       localizedReason:@"Please login through TouchID" 
          reply: 
     ^(BOOL success, NSError *authenticationError) { 

      dispatch_async(dispatch_get_main_queue(), ^{ 

       if (success) { 
        [SVProgressHUD showSuccessWithStatus:@"Everything Worked!"]; 
        //Code for new viewController should come here! 
       } 
       else { 
        NSLog(@"error:%@", authenticationError); 
        [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"FAILED! %@", authenticationError.localizedDescription]]; 
       } 
      }); 
     }]; 
    } 


- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 

viewController.h是非標準。沒有什麼改變。 感謝支持:)

回答

1

爲了呈現我們如果我們使用故事板,通常使用以下方法

  1. 視圖控制器然後調用以下方法

    [self performSegueWithIdentifier:@"indentifierForViewController" sender:self];

  2. 如果我們不使用故事板,那麼我們可以使用

NextTaskViewControler *add = [[NextTaskViewControler alloc] initWithNibName:@"NextTaskViewController" bundle:nil]; [self presentViewController:nextTaskVC animated:YES completion:nil];

我建議你使用的UINavigationController,管理其他視圖控制器爲用戶提供分層導航一個專門的視圖控制器。呈現視圖控制器只能用於特定目的,如呈現與幾個動作的照片,以it.It的易維護時視圖層次結構變得複雜

請到通UINavigationController Refrence