但是我们想要让textfield中的值发生变化时我们就能够监听的到.
这时我们要调用 addtarget 方法,为textfiled添加一个UIControlEventAllEditingEvents事件然后,再反法中判断textfeild.text是否发生了改变就可以了.
我们还会遇到一些收回键盘的问题,这里提供一种比较普遍的做法就是添加键盘上的View,其类型是UIToolBar
-(UIToolbar *)GetToolbar
{
UIToolbar * topView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 30)];
[topView setBarStyle:UIBarStyleDefault];
UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace, doneButton, nil];
[topView setItems:buttonsArray];
return topView;
}