Objective c 如何在tableView委托方法之外查找单元格文本字段?

Objective c 如何在tableView委托方法之外查找单元格文本字段?,objective-c,uitableview,storyboard,ui-design,Objective C,Uitableview,Storyboard,Ui Design,我有一个带有文本字段的自定义tableView单元格。现在,我想识别tableView委托方法之外的textField。我试过这个- UIView *cell = textField; [cell isKindOfClass:[UITableViewCell class]]; 但它不起作用。要从表视图中获取具体单元格,您需要知道该单元格的索引路径。然后你需要做: NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:

我有一个带有文本字段的自定义tableView单元格。现在,我想识别tableView委托方法之外的textField。我试过这个-

UIView *cell = textField;
[cell isKindOfClass:[UITableViewCell class]];

但它不起作用。

要从表视图中获取具体单元格,您需要知道该单元格的索引路径。然后你需要做:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];  //you should set your indexes of row and section instead of zeros
MyCustomCell *cell = [myTableView cellForRowAtIndexPath:indexPath];
现在,如果文本字段是自定义单元格的属性,则可以使用
cell.myTextField

例如:

UITextField *textField = cell.myTextField;

现在您可以用它做任何您想做的事情。

要从表视图中获得具体的单元格,您需要知道该单元格的索引路径。然后你需要做:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];  //you should set your indexes of row and section instead of zeros
MyCustomCell *cell = [myTableView cellForRowAtIndexPath:indexPath];
现在,如果文本字段是自定义单元格的属性,则可以使用
cell.myTextField

例如:

UITextField *textField = cell.myTextField;

现在你可以用它做你想做的事。

看起来你需要整个单元格,而不仅仅是文本字段。你需要为这个提供更多的上下文…检查下面的链接,一旦它可能对你有用,似乎你需要整个单元格,而不仅仅是文本字段。您需要为此提供更多的上下文…一旦它可能对您有用,请检查下面的链接