【发布时间】:2014-10-30 09:56:10
【问题描述】:
您好,我遇到了一种我真的不明白的奇怪行为。
我向用户出示 Touch ID 标识,如果他获得授权,我 调用 [self performSegueWithIdentifier: @"callCustomSegue" sender:self]; 以这种方式在块内:
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
[self performSegueWithIdentifier: @"callCustomSegue" sender:self];
然后应用程序停止几秒钟(至少 3-4 秒),然后呈现下一个 ViewController。
“callCustomSegue”调用的执行是这样做的:
- (void) perform {
src = (UIViewController *) self.sourceViewController;
dst = (UIViewController *) self.destinationViewController;
[src.view addSubview:dst.view];
}
我不明白 touch ID 上的标识和 performSegueWithIdentifier 之间发生了什么 以及应用停止的原因。
如果我绕过触摸 ID 并调用 performSegueWithIdentifier 会立即按我的预期工作。
如果我放入触摸 ID 块:
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
authenticated = YES;
[self showMessage:@"Authentication is successful" withTitle:@"Success"];
}
showMessage 在哪里执行此操作:
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
if (authenticated) {
[self performSegueWithIdentifier: @"callCustomSegue" sender:self];
}
if (!authenticated) {
[self touchID];
}
}];
点击 OK 后会立即调用下一个 ViewController。
所以问题是:为什么我不能在 touch ID 块中调用 performSegue 并立即得到响应?
知道我哪里错了吗?
非常感谢。
【问题讨论】:
标签: ios uistoryboardsegue touch-id