如何用Swift语言指定textfield或任何委托?

如何用Swift语言指定textfield或任何委托?,swift,delegates,uitextfield,Swift,Delegates,Uitextfield,我只是Swift语言的新开发人员。 我想将textfield委派给视图控制器。我试着这样分配 class LoginViewController: UIViewController <UITextFieldDelegate> 类LoginViewController:UIViewController 它返回以下错误“无法专门化非泛型类型“UIViewController”您需要使用逗号添加要符合的协议: class LoginViewController: UIViewContr

我只是Swift语言的新开发人员。 我想将textfield委派给视图控制器。我试着这样分配

class LoginViewController: UIViewController <UITextFieldDelegate>
类LoginViewController:UIViewController

它返回以下错误“无法专门化非泛型类型“UIViewController”

您需要使用逗号添加要符合的协议:

class LoginViewController: UIViewController, UITextFieldDelegate
您只能从一个类进行扩展,但要遵守任意多个协议:

    class LoginViewController: UIViewController, UITextFieldDelegate, UIAlertViewDelegate
发件人:


您需要使用逗号添加要符合的协议:

class LoginViewController: UIViewController, UITextFieldDelegate
您只能从一个类进行扩展,但要遵守任意多个协议:

    class LoginViewController: UIViewController, UITextFieldDelegate, UIAlertViewDelegate
发件人:


请使用逗号添加委托/数据源/协议:

class MyClass:UIViewController、UITableViewDelegate、UITableViewDataSource。。

{…}

请使用逗号添加委托/数据源/协议:

class MyClass:UIViewController、UITableViewDelegate、UITableViewDataSource。。

{…}

我想补充一点,您可以通过遵守类的
扩展中的协议来分离代码以提高可读性:

class DetailViewController: UIViewController {

    [your class implementation]

}

extension DetailViewController: UICollectionViewDelegate, UICollectionViewDataSource {

    [list of your delegate methods]

}

就个人而言,我更喜欢这种方法。

我想补充一点,您可以通过遵守类的
扩展中的协议来分离代码,以提高可读性:

class DetailViewController: UIViewController {

    [your class implementation]

}

extension DetailViewController: UICollectionViewDelegate, UICollectionViewDataSource {

    [list of your delegate methods]

}

就我个人而言,我更喜欢这种方法。

如果有多个代表,该怎么办?类LoginViewController:UIViewController、UIExtFieldDelegate、UIExtViewDelegate这是合适的方法吗?更新的答案:是的,这是做得很好的方法+1获取快速帮助。如果有多个代表,该怎么办?类LoginViewController:UIViewController、UIExtFieldDelegate、UIExtViewDelegate这是合适的方法吗?更新的答案:是的,这是做得很好的方法+1.寻求快速帮助。