如何在设置页面中打开TouchID页面?

时间:2017-06-30 02:13:02

标签: ios objective-c iphone

我是Objective-C的新手。我想在iPhone设置页面中打开TouchID页面,但我的代码只是打开在线公共源中的设置页面。我写了下面的代码。

======打开iPhone设置页面=======

if (&UIApplicationOpenSettingsURLString != NULL)
    {
        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        [[UIApplication sharedApplication] openURL:url];
        NSLog(@"&UIApplicationOpenSettingsURLString != NULL");
    }
    else
    {
        // Present some dialog telling the user to open the settings app.
        NSLog(@"&UIApplicationOpenSettingsURLString == NULL");
    }

如何修改代码以解决此问题?

1 个答案:

答案 0 :(得分:0)

修改

此解决方案不再适用于iOS 11 +

在iOS 10之前,您无法执行此操作。

话虽如此,你必须"发现"什么是网址。

您可以尝试以下代码:

// URL to open general settings in case the TouchID one was not found.
NSString * defaultSettingsStr = ( &UIApplicationOpenSettingsURLString != NULL ? UIApplicationOpenSettingsURLString : @"prefs:root" );

// Array of possible URLs, differ in various iOS versions
NSArray * urlStrs = @[@"App-Prefs:root=TOUCHID_PASSCODE",
                 @"Prefs:root=TOUCHID_PASSCODE",
                 defaultSettingsStr];

for (NSString * urlStr in urlStrs) {
   NSURL * url = [NSURL URLWithString:urlStr];

   if ([[UIApplication sharedApplication] canOpenURL:url]) {
       // openURL is deprecated since iOS 10
       [[UIApplication sharedApplication] openURL:url];
       break;
   }
}