【问题标题】:popViewController and then immediately present an alert controllerpopViewController 然后立即呈现一个警报控制器
【发布时间】:2020-06-05 10:45:51
【问题描述】:

我正在尝试从警报操作中弹出控制器并进入另一个视图控制器。我想在进入另一个控制器后立即执行一些操作,比如打开另一个警报控制器。我该怎么做?

UIAlertController.getAlertView("Success", message: "Your password has been successfully changed!", cancelButtonTitle: "Ok", cancelHandler: { (action) in
 self.navigationController?.popViewController(animated: true)
                        }).show(self)

【问题讨论】:

    标签: navigation uinavigationcontroller uialertcontroller popviewcontroller uialertviewcontroller


    【解决方案1】:

    如果您想在单击警报操作时返回上一个 viewController,那么下面的代码将为您提供帮助。

        let alert = UIAlertController(title: "Success", message: "Your password has been successfully changed!", preferredStyle: UIAlertController.Style.alert)
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: { action in
            //perfoem any action you want on click of OK
                        self.navigationController?.popViewController(animated: true)
                    }))
        self.present(alert, animated: true, completion: nil)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多