ios - 指纹认证后 UIBarButtonItem 不出现

标签 ios swift authentication touch-id

我正在创建一个应用程序,要访问该应用程序的主屏幕,用户必须在那里输入指纹。我设置了它,以便当 fingerprint 正确时,它以编程方式对连接到 main 的 navigation controller 执行 segue View Controller 。这是我的代码:

    let context = LAContext()
    var error: NSError?

    if context.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: &error) {

        let reason = "Authenticate with Touch ID"

        context.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: reason, reply:
            {(succes: Bool, error: NSError!) in

                if succes {

                    self.showOrHide(true)
                    ProgressHUD.showSuccess("Success")

                    self.performSegueWithIdentifier("passwordCorrectSegue", sender: nil)

                } else {

                }

        })

    } else {

        self.touchIDLabel.hidden = true
        self.touchIDImage.hidden = true

    }

问题是当我执行segue时,它会转到显示view controllerUIBarButtonItem 的navigation controller 不显示在屏幕的左上角和右上角。您仍然可以单击屏幕的左上角和右上角,这些按钮的操作将会运行。问题是 UIBarButtonItem 的 没有显示。我尝试过的另一件事是,您还可以选择输入密码,当密码正确时,它会转到下一个 view controller... 并且效果很好。有谁知道如何解决这个问题?

当我使用该方法时,UIBarButtonItems 只是不显示

self.performSegueWithIdentifier("passwordCorrectSegue", sender: nil)

尝试使用指纹方法执行该方法时。

最佳答案

我遇到了完全相同的问题:我有 2 个 VC,每个都可以连接到第三个;如果我从第一个开始,右栏按钮项目不可见(但仍然有效),但如果我从第二个开始,右栏按钮项目可见。

我猜这是 iOS9 中的一个错误。

我使用的解决方法是强制初始化目标 View Controller “viewDidLoad”中的右侧栏按钮项目:

override func viewDidLoad() {
    super.viewDidLoad()

    // Force right bar button item when using performSeguewithIdentifier (bug in iOS9?)
    navigationItem.rightBarButtonItem = UIBarButtonItem(
    image: UIImage(assetIdentifier: .Profile),
    style: UIBarButtonItemStyle.Plain,
    target: self,
    action: Selector("displayUser"))
}

这为我解决了问题(至少在 Apple 修复此错误之前)。

关于ios - 指纹认证后 UIBarButtonItem 不出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32017942/

相关文章:

swift - 如何快速获取多个音频的混合并将其保存为单个音频

javascript - 针对 Laravel 后端的 Angular Auth

php - 无法让登录页面重定向到安全页面

ios - 在iPhone 5/iPad第4代上安装R(统计计算项目)(ARM v7s指令集)

ios - 我应该在我的 TableView 中使用 4 xib 还是使用 4 个不同的 TableView

ios - 如何在iOS中强制将音频输出路由到蓝牙A2DP?

随时间快速移动物体

ios - 如何使 subview 调整大小为 UIScrollView ContentSize?

JAVA相当于验证登录信息?

ios - TestFlight不会发送通知