//通知
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
//注册通知
[center addObserver:self selector:@selector(textValueChanged:) name:UITextFieldTextDidChangeNotification object:_textf];
#pragma mark 监听文本框内容
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
_str = [NSMutableString stringWithString:textField.text];
[_str replaceCharactersInRange:range withString:string];
NSLog(@"%@",_str);
_st=[NSMutableString stringWithFormat:@"%@.00",self.str];
return YES;
}
///监听文本框的值的改变
- (void)textValueChanged:(NSNotification *)notice
{
if([_textf.text isEqual: @""] ){
_btn.enabled = NO;
}else{
// _btn.enabled=NO;
}
}
//移除通知
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
ios 监听注册通知 移除通知
最新推荐文章于 2024-08-05 16:57:27 发布