您的位置:首页 > 其它

监听textfiled文字的编辑结束

2016-02-22 21:10 218 查看
如果要监听textfiled文字的编辑结束,可以使用通知,通知的方法名是UITextFieldTextDidChangeNotification,然后再方法中判断文字的长度,如果为0的话,可以做一下想做的事情.[/b]

下面是代码[/b]

-
(
void)viewDidLoad
{


   
[
super
viewDidLoad];

  
 


   
[[
NSNotificationCenter
defaultCenter]addObserver:self
selector:@selector(textFieldTextDidChangeOneCI:)
name:UITextFieldTextDidChangeNotification
object:self.searchTextField];

}[/b]

-(void)textFieldTextDidChangeOneCI:(NSNotification
*)notification

{

   
UITextField
*textfield=[notification
object];

  
 


   
if
(textfield.text.length
== 0)
{


    
   


   
   

NSLog(@"文本框中的文字被删除完啦"); 
    [/b]

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: