快速创建自定义的Alert Controller初始化程序

时间:2019-01-08 17:32:17

标签: ios swift uialertcontroller

我正在实现UIAlertController以便在重置用户密码时进行确认。我创建了一个自UIAlertController继承的自定义类。我还对文档中看到的类进行了初始化。

import UIKit

class PasswordResetConfirmationViewController: UIAlertController {

    init() {
        super.init(title: "Are you sure you would like to reset your password?",message: "",preferredStyle: .alert)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
}

奇怪的是,我收到此错误,必须在xcode中调用超类'UIAlertController'的指定初始化程序。 这是UIAlertController的初始化

init(title: String?, 
         message: String?, 
  preferredStyle: UIAlertController.Style)

我不确定是什么原因在xcode中产生了此错误,所以任何帮助都不会很大。

0 个答案:

没有答案