无法将"联系人列表"类型的值转换为预期的参数类型"UIViewController"



这是代码

let logButton : UIButton = {
    let login = UIButton()

    login.translatesAutoresizingMaskIntoConstraints = false
    login.setTitle("Login", for: .normal)
    login.setTitleColor(UIColor.white, for: .normal)
    login.backgroundColor = UIColor(red: 0/255, green: 61/255, blue: 114/255, alpha: 1.0)
    login.addTarget(self, action: #selector(loginButton), for: .touchUpInside)
    return login
}()

@objc func loginButton(){
    let contactList = listOfContacts()
    present(contactList, animated: true, completion: nil)
}

无法将'listOfContacts'类型的值转换为预期参数类型'uiviewController'

请为此提供建议或解决方案

您的问题在这里

 let contactList = listOfContacts()
 present(contactList, animated: true, completion: nil)

您正在尝试将listOfContacts类型的ContactList用作present方法的参数,该方法将UIViewController的类型作为第一个参数,该参数是应该呈现的VC

这是方法签名

func present(_ viewControllerToPresent: UIViewController,animated flag: Bool,completion: (() -> Void)? = nil)

最新更新