这是代码
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)
}
Cannot convert value of type 'listOfContacts' to expected argument type '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)
关于ios - 无法将类型 'listOfContacts' 的值转换为预期参数类型 'UIViewController',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48719419/