Por que o UITextField é bloqueado ao se definir para delegar
Eu tenho uma classe que estende UITextfield. Eu também tenho a mesma classe definida para ser o próprio delegado, assim quando o campo de texto é selecionado, eu posso mudar a cor de fundo. Depois de selecionar o campo de texto e digitar algumas letras, o aplicativo trava e trava.
aqui está o que meu arquivo .m parece
@implementation MyTextField
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.delegate = self;
}
return self;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
NSLog(@"run did begine editing");
[self setBackgroundColor:[UIColor colorWithRed:0.204 green:0.239 blue:0.275 alpha:0.25]];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
NSLog(@"run did end editing");
[self setBackgroundColor:[UIColor clearColor]];
}
aqui é o .h
@interface MyTextField : UITextField <UITextFieldDelegate>
@end