[英]Load another View after successful TouchID login
I played around a bit with TouchID and I have the following question: 我用TouchID玩了一下,我有以下问题:
After successful TouchID login, how do I present a new ViewController? 成功登录TouchID后,如何显示新的ViewController?
The code in the viewController.m is: 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 is standart. viewController.h是标准的。 Nothing changed in it.
它什么都没有改变。 Thanks for support :)
感谢你的支持 :)
To present a view controller we normally use following methods 为了呈现视图控制器,我们通常使用以下方法
If we are using storyboard,then call following method 如果我们使用情节提要,则调用以下方法
[self performSegueWithIdentifier:@"indentifierForViewController" sender:self];
NextTaskViewControler *add = [[NextTaskViewControler alloc] initWithNibName:@"NextTaskViewController" bundle:nil]; [self presentViewController:nextTaskVC animated:YES completion:nil];
I suggest you to use UINavigationController, a specialized view controller that manages other view controllers to provide a hierarchical navigation for the user. 我建议您使用UINavigationController,这是专门的视图控制器,可以管理其他视图控制器以为用户提供分层导航。 Present a viewcontroller only for specific purpose such as presenting a photo with few actions in it.It's easy to maintain when view hierarchy becomes complex
仅出于特定目的呈现视图控制器,例如呈现几乎没有动作的照片。当视图层次变得复杂时,易于维护
Please go-through UINavigationController Refrence 请通过UINavigationController Refrence
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.