UITextField控件之ValueChanged事件
来源:互联网 发布:阿里云计算认证考试 编辑:程序博客网 时间:2024/06/05 01:06
From: http://wuchaorang.2008.blog.163.com/blog/static/48891852201402184156861/
1.UITextField的UIControlEventValueChanged事件单独注册,你会发现根本不执行,需要多注册一个通知事件,才可以监听到UITextField的值改变事件
2.举例说明:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldChange:) name:UITextFieldTextDidChangeNotification object:nil];
- (void)dealloc{
[super dealloc];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
UITextField *textField=[[UITextField alloc] initWithFrame:CGRectMake(10, 10, 300, 35)];
textField.borderStyle=UITextBorderStyleRoundedRect;
textField.contentHorizontalAlignment=UIControlContentVerticalAlignmentCenter;
//UITextFieldTextDidChangeNotification通知事件
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldChange:) name:UITextFieldTextDidChangeNotification object:nil];
//注册UIControlEventValueChanged事件
[textField addTarget:self action:@selector(textFieldChange:) forControlEvents:UIControlEventValueChanged];
//添加到页面
[self.view addSubView: textField];
[textField release];
}
- (void)textFieldChange:(NSNotification*)notifice{
UITextField *field=[notifice object];
NSLog(@"text=%@",field.text);
}
- UITextField控件之ValueChanged事件
- [VB.NET]TextChanged ValueChanged 事件
- NumericUpDown控件ValueChanged事件获取的数值是上一次数据的问题解决
- 基本控件之UITextField
- iOS控件之UITextField
- iOS控件之UITextField篇
- ios基本控件之UITextField
- 学习iOS控件之UITextField
- swift控件之旅之UITextField
- IOS之监听UITextField的编辑事件
- IOS之监听UITextField的编辑事件
- UITextField事件
- IOS开发(13)之UITextField控件
- iOS 6常用控件之UITextField
- objective-c-UI控件之-UITextField-placeholder
- objective-c-UI控件之-UITextField-clearButtonMode
- iOS-UI-基本控件之UITextField
- 控件--UITextField
- 求全组合
- App模块化及工程扩展
- cocos2d-x v3.2 FlappyBird 各个类对象具体代码分析(2)
- try_module_get和module_put
- Flex更改Alert提示框的字体大小和样式
- UITextField控件之ValueChanged事件
- 《UNIX环境高级编程》读书笔记之文件与目录(2)
- HDU-1548 A strange lift
- [解决]Xcode6模拟器虚拟键盘不显示
- Web 应用层分类和识别
- typedef和#define
- HTTP使用BASIC认证的原理及实现方法
- 今年暑假不AC(贪心--区间调度)
- GARCH(二)