控件监听方法

1.是否继承UIControl
    查看控件是否有 addTarget 方法

2.查看控件是否有delegate

3.查看代理是否有通知功能
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textfieldChange) name:UITextFieldTextDidChangeNotification object:self.textF];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textfieldChange) name:UITextFieldTextDidChangeNotification object:self.PwdF];

    - (void)dealloc{
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }    


    - (void)textfieldChange{
        self.LoginBtn.enabled = (self.textF.text.length && self.PwdF.text.length);
    }

你可能感兴趣的:(控件监听方法)