3
我想在touch id被問到的時候模糊背景,一旦授權成功,viewcontroller需要可見。但是這並沒有發生。即使授權成功,viewcontroller仍然模糊不清有人可以幫我解決這個問題嗎?removeFromSuperview()不起作用
import UIKit
import LocalAuthentication
class TabBarViewController: UITabBarController {
@IBOutlet weak var noteTabBar: UITabBar!
override func viewDidLoad() {
super.viewDidLoad()
self.authenticateUser()
self.tabBar.hidden = false
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
let userDefaults = NSUserDefaults.standardUserDefaults()
userDefaults.setObject(false, forKey: "sendModeToggle")
userDefaults.setObject("Avenir-Medium", forKey: "font")
userDefaults.setObject(13, forKey:"fontSize")
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
// MARK: Touch ID Authentication
func authenticateUser()
{
let context = LAContext()
var error: NSError?
let reasonString = "Authentication is needed to access your app! :)"
let blurEffect = UIBlurEffect(style: .Light)
let blurVisualEffectView = UIVisualEffectView(effect: blurEffect)
blurVisualEffectView.frame = view.bounds
self.view.addSubview(blurVisualEffectView)
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &error)
{
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: reasonString, reply: { (success, policyError) -> Void in
if success
{
print("Authentication successful! :) ")
blurVisualEffectView.removeFromSuperview()
}
else
{
switch policyError!.code
{
case LAError.SystemCancel.rawValue:
print("Authentication was cancelled by the system.")
/*case LAError.UserCancel.rawValue:
print("Authentication was cancelled by the user.")
*/
case LAError.UserFallback.rawValue:
print("User selected to enter password.")
NSOperationQueue.mainQueue().addOperationWithBlock({() -> Void in
self.showPasswordAlert()
blurVisualEffectView.removeFromSuperview()
})
default:
print("Authentication failed! :(")
NSOperationQueue.mainQueue().addOperationWithBlock({() -> Void in
self.showPasswordAlert()
blurVisualEffectView.removeFromSuperview()
})
}
}
})
}
else
{
print(error?.localizedDescription)
NSOperationQueue.mainQueue().addOperationWithBlock({() -> Void in
self.showPasswordAlert()
})
}
}
}
嘗試過,但我得到了一些錯誤 的參數#2人失蹤的說法呼叫 預計表達的表達式列表 請幫我這個 –
@ VineethKrishnan對不起,我忘了關閉括號。立即試用 –
非常感謝所有工作都很好 –