Why does UITextField lock up when setting itself to delegate

前端 未结 3 913
刺人心
刺人心 2021-01-16 02:46

I have a class that extends UITextfield. I also have the same class set to be it\'s own delegate so when the text field is selected I can change the background color. Once I

3条回答
  •  野的像风
    2021-01-16 03:22

    The delegate is always another UIViewController as the events are delegated to it by another class where protocol is defined.

    There's no need of delegate methods in the same class when you can access all the variables and methods in the same class.

    you simply can call [self someFunction].

    As you are inheriting the UITextField , you don't need to define even a property for the UITextField delegate.You just need to set it a different viewController.

    Also the class defining the protocol just has the declaration and it does not conform to the protocol.

    The delegate will be the class which conforms to the protocol.

提交回复
热议问题