Gre*_*reg 0 iphone uitextfield ios uitextfielddelegate
我在视图中有多个UITextFields.
我假设一旦用户离开它就是捕获UITextField的线索的地方是实现委托方法"textFieldShouldReturn".
问题 - textFieldShouldReturn然而,在" "中,如何判断哪个UITextField触发了这个?
例如,假设在此阶段我现在需要使用UITextField现在显示的值来更新我的数据模型,因此需要更新模型中与该特定UITextField对齐的正确字段.
PS如果有更好的方法,或者某种"绑定"方法的方法,我很想知道我会感兴趣
...或者您可以跳过所有标记并制作UITextViews实例变量并执行以下操作:
- (void)viewDidLoad {
myTextView1 = [[UITextView alloc] init];
myTextView2 = [[UITextView alloc] init];
myTextView3 = [[UITextView alloc] init];
myTextView4 = [[UITextView alloc] init];
......
}
- (void)textFieldShouldReturn:(UITextField *)textField {
BOOL shouldReturn = NO;
if (textField == myTextView1)
{
shouldReturn = YES;
}
...and so on...
}
... release the instance vars in the dealloc...
Run Code Online (Sandbox Code Playgroud)
我有点喜欢这种方式,但另一个答案也会有用.
| 归档时间: |
|
| 查看次数: |
489 次 |
| 最近记录: |