【发布时间】:2013-07-11 15:23:43
【问题描述】:
我将UITableView 分组,其中包含几个自定义单元格,我在其中放置了文本字段。我已经定义了一个指向当前处于活动状态的文本字段的属性:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
self.activeTextField = textField;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
self.activeTextField = nil;
}
我需要获取包含此类文本字段的单元格的行和部分。我试过这个:
UITableViewCell *parentCell = (UITableViewCell *)[self.activeTextField superview];
NSIndexPath* cellPath = [self.tableView indexPathForCell:parentCell];
NSInteger cellRow = [cellPath row];
但我总是得到一个 0。看起来 parentCell 实际上不是 UITableViewCell(但应该是)。我怎样才能得到这些值?
谢谢
【问题讨论】:
标签: ios uitableview row nsindexpath