Passcode Controller¶
FUIPasscodeController
¶
open class FUIPasscodeController: UIViewController, FUIPrivateEncryptionKeyGenerator
This is the base class of FUIPasscodeCreateController
and FUIPasscodeInputController
.
It has the common codes for those two view controllers.
Note that both Passcode screen and Touch ID screen are supported for iPad portrait and landscape orientation and iPhone portrait orientation only.
Since the screens are not supported in iPhone landscape orientation, the app installed in iPhone needs to switch to portrait mode before presenting these screens.
And AppDelegate
needs to lock the screen orientation when these screens are shown, similar to the following code snippet.
In app's AppDelegate
:
public var inPasscodeView: Bool = false
// implement this function to support only portrait orientation when FUPasscodeView is displayed in iPhone.
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if !inPasscodeView {
return .allButUpsideDown
} else {
return .portrait
}
}
Before presenting the Passcode or Touch ID screen:
// Let `AppDelegate` know that we are entering FUIPasscodeView
(UIApplication.shared.delegate as! AppDelegate).inPasscodeView = true
// Make sure we rotate to portrait mode
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
// Present the passcode view
self.navigationController?.present(navController, animated: true, completion: nil)
After dismissing the Passcode or Touch ID screen:
passcodeController.dismiss(animated: true, completion: nil)
// Let `AppDelegate` know that we are exiting FUIPasscodeView
(UIApplication.shared.delegate as! AppDelegate).inPasscodeView = false
The strings used in FUIPasscodeSetupView
, FUIPasscodeView
, and FUITouchIDView
are from localized Onboarding.strings file.
Application can override these strings by setting the corresponding static
variables in this FUIPasscodeController
class at runtime.
Theming¶
Supported style classes
fdlFUIPasscodeController
fdlFUIPasscodeController_navigationController_navigationBar
Attention¶
The delegate object with type FUIPasscodeControllerDelegate
is declared as a weak reference. On deallocation it will be automatically set to nil. To keep it alive as expected, developer should retain the delegate object during its whole execution scope.