[英]How to get text of uitextfields in table view.?
How to get values of textfields in tableview in ios5? 如何在iOS5的TableView中获取文本字段的值? I have tried tags but its not working.
我已经尝试过标签,但无法正常工作。
Probably you use custom cells. 可能您使用自定义单元格。 If you want to get text values when cell become selected (you need to set tag for UITextField when you create it or in xib file):
如果要在选择单元格时获取文本值(创建时或在xib文件中需要为UITextField设置标签):
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITextField *textField = [[tableView cellForRowAtIndexPath:indexPath] viewWithTag:1];
NSSTring *text = textField.text;
}
Or you can set delegate to UITextField when you create cell 或者您可以在创建单元格时将委托设置为UITextField
In 在
- (UITableViewCell*)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
Set delegate 设置代表
UITextField *textField = [cell viewWithTag:1];
textField.delegate = self;
You can read about UITextField delegate here 您可以在此处了解有关UITextField委托的信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.