Центр представления предупреждений изменяется, когда в корневом представлении отображается другое представление - PullRequest
0 голосов
/ 04 октября 2018

В приложении отображается предупреждение, когда нет подключения к Интернету (отображается на контроллере корневого представления).В приложении также есть Biometric authentication.Таким образом, всякий раз, когда появляется биометрическая страница (биометрическая страница также отображается на контроллере корневого представления) в верхней части alertview и удаляет ее из представления, представление предупреждений ограничений изменяется и не отображается в середине.

Шаг 1: -

Показывает сообщение об ошибке

enter image description here

Отображение кода предупреждения: -

  func showAlert(title:String, message: String, buttons: [UIAlertAction]) {
    // create the alert
    self.alert.title = title
    self.alert.message = message

    // add an action (button)
    if buttons.count == 0 {
        self.alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
    } else {
        for i in 0...buttons.count-1 {
            self.alert.addAction(buttons[i])
        }
    }
    self.viewController.present(alert, animated: true, completion: nil)
}

Шаг 2: -

Выйдите из приложения и отобразите вид биометрической проверки.

Файл делегата приложения: -

   func applicationDidBecomeActive(_ application: UIApplication) {

    if self.userToken != "" && self.biometricStatus && !UserAccessTemp.isBiometricActive {

        let controller = BiometricCheckViewController.instantiate(fromAppStoryboard: .BiometricCheck)
        if let window = self.window, let rootViewController = window.rootViewController {
            var currentController = rootViewController
            while let presentedController = currentController.presentedViewController {
                currentController = presentedController
            }
            currentController.present(controller, animated: true, completion: nil)
        }

    }

enter image description here

Шаг 3: -

Изменения выравнивания в режиме просмотра предупреждений после отклонения вида биометрической проверки

enter image description here

Так как я могу перецентрировать представление предупреждений после отклонения биометрического представления?

Ответы [ 2 ]

0 голосов
/ 04 октября 2018

попробуй:

func showAlert(title:String, message: String, buttons: [UIAlertAction]) {
    // create the alert
    self.alert.title = title
    self.alert.message = message

    // add an action (button)
    if buttons.count == 0 {
        self.alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
    } else {
        for i in 0...buttons.count-1 {
            self.alert.addAction(buttons[i])
        }
    }

    if var topController = UIApplication.sharedApplication().keyWindow?.rootViewController {
        while let presentedViewController = topController.presentedViewController {
            topController = presentedViewController
        }

        topController.present(alert, animated: true, completion: nil)
    }
}
0 голосов
/ 04 октября 2018

Просто поместите makeKeyAndVisible() в биометрический вид, и это решит проблему.Благодаря комментарию Дипики.

func applicationDidBecomeActive(_ application: UIApplication) {

    if self.userToken != "" && self.biometricStatus && !UserAccessTemp.isBiometricActive {

        let controller = BiometricCheckViewController.instantiate(fromAppStoryboard: .BiometricCheck)

        let alertWindow = UIWindow(frame: UIScreen.main.bounds)
        alertWindow.rootViewController = UIViewController()
        alertWindow.windowLevel = UIWindowLevelAlert + 1;
        alertWindow.makeKeyAndVisible()
        alertWindow.rootViewController?.present(controller, animated: true, completion: nil)
    }
}
...