简体   繁体   English

如何在表视图中获取uitextfields的文本?

[英]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.

相关问题 在iPhone版Titanium中,如何从表格视图过渡到详细视图。 - in Titanium for iPhone, how to transition from table view to detail view.? 如何在离开表格视图之前显示警报? - How to show an alert before leaving the table view.? 如何在iOS 9中获得堆叠的UITextFields - How to get stacked UITextFields in iOS 9 从自定义UITableView获取UItextFields文本 - Get UItextFields text from custom UITableView 需要有关表格视图详细信息视图的帮助。 我似乎无法将值写入UILabel的text属性? - Need help with table view detail view. I can't seem to write values to the UILabel's text property? UILabel重绘视图。 如何避免这种行为? - UILabel redraws the view. How to avoid this behavior? 将数据从表视图单元格嵌入并传输到多个Uitextfields - Embedding and transferring data from table view cell to multiple Uitextfields UITableViewCells内部的UITextFields-当单元格不在视野中时,文本消失 - UITextFields inside UITableViewCells - text disappears when cells go out of view 检查UITextFields是否有文字 - Check UITextFields for text 如何使用 UITextFields 在同一视图 controller 中使用多个 UIPickerViews - How to use Multiple UIPickerViews in same View controller using UITextFields
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM