如何在ios5中获取tableview中文本字段的值?我已经尝试过标签,但它不起作用。
最佳答案
您可能使用自定义单元格。 如果您想在单元格被选中时获取文本值(您需要在创建 UITextField 时或在 xib 文件中为 UITextField 设置标签):
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITextField *textField = [[tableView cellForRowAtIndexPath:indexPath] viewWithTag:1];
NSSTring *text = textField.text;
}
或者您可以在创建单元格时将委托(delegate)设置为 UITextField
在
- (UITableViewCell*)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
设置委托(delegate)
UITextField *textField = [cell viewWithTag:1];
textField.delegate = self;
您可以阅读有关 UITextField 委托(delegate)的信息 here
关于objective-c - 如何在 TableView 中获取 uitextfields 的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9548553/