Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在IOS 7中,如何获取表格视图单元格中的文本框索引_Ios_Uitableview_Ios7_Nsindexpath - Fatal编程技术网

在IOS 7中,如何获取表格视图单元格中的文本框索引

在IOS 7中,如何获取表格视图单元格中的文本框索引,ios,uitableview,ios7,nsindexpath,Ios,Uitableview,Ios7,Nsindexpath,我想在tableview单元格中获取触摸文本框的索引。事实上我可以在IOS 7之前完成。在过去,我可以得到下面的文本框索引。此方法也无法用于IOS 7。我读标签应该使用而不是这个方法。但我也为每个不同的文本框使用标记。因为单击文本框,我正在执行不同的操作,例如打开选择器或打开选择视图。请帮助我,当触摸到文本框时,如何获取每个文本框的行号 请尝试使用以下代码: UIView *contentView = (UIVIew *)[textfield superview]; UITableViewCe

我想在tableview单元格中获取触摸文本框的索引。事实上我可以在IOS 7之前完成。在过去,我可以得到下面的文本框索引。此方法也无法用于IOS 7。我读标签应该使用而不是这个方法。但我也为每个不同的文本框使用标记。因为单击文本框,我正在执行不同的操作,例如打开选择器或打开选择视图。请帮助我,当触摸到文本框时,如何获取每个文本框的行号


请尝试使用以下代码:

UIView *contentView = (UIVIew *)[textfield superview];
UITableViewCell *cell = (UITableViewCell *)[contentView superview];
NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
NSLog(@"%d", indexPath.row);
UITableViewCell *cell = (UITableViewCell *)[[contentView superview] superview];
但在iOS 7中,您可以通过以下代码获得
UITableViewCell

UIView *contentView = (UIVIew *)[textfield superview];
UITableViewCell *cell = (UITableViewCell *)[contentView superview];
NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
NSLog(@"%d", indexPath.row);
UITableViewCell *cell = (UITableViewCell *)[[contentView superview] superview];

请尝试使用以下代码:

UIView *contentView = (UIVIew *)[textfield superview];
UITableViewCell *cell = (UITableViewCell *)[contentView superview];
NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
NSLog(@"%d", indexPath.row);
UITableViewCell *cell = (UITableViewCell *)[[contentView superview] superview];
但在iOS 7中,您可以通过以下代码获得
UITableViewCell

UIView *contentView = (UIVIew *)[textfield superview];
UITableViewCell *cell = (UITableViewCell *)[contentView superview];
NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
NSLog(@"%d", indexPath.row);
UITableViewCell *cell = (UITableViewCell *)[[contentView superview] superview];
好的,我解决了

-(NSIndexPath *) getButtonCellRow:(UITextField *) b {
    UITableView *tv = nil;
    UIView *superViewTemp = [b superview];
    UITableViewCell *cell=nil;

    BOOL isFoundTable=FALSE;
    BOOL isFoundCell=FALSE;

    while(superViewTemp != nil && ![superViewTemp isKindOfClass:[UIWindow class]]){

        if ([superViewTemp isKindOfClass:[UITableViewCell class]]) {
            cell=(UITableViewCell*)superViewTemp;
            isFoundCell = TRUE;

        }else if ([superViewTemp isKindOfClass:[UITableView class]]){
            tv = (UITableView*)superViewTemp;
            isFoundTable = TRUE;
        }

        superViewTemp = [superViewTemp superview];

        if(isFoundCell && isFoundTable){
            break;
        }
    }

    if(tv != nil && cell != nil){

        return [tv indexPathForCell:(UITableViewCell*)cell];
    }
    return nil;
}
好的,我解决了

-(NSIndexPath *) getButtonCellRow:(UITextField *) b {
    UITableView *tv = nil;
    UIView *superViewTemp = [b superview];
    UITableViewCell *cell=nil;

    BOOL isFoundTable=FALSE;
    BOOL isFoundCell=FALSE;

    while(superViewTemp != nil && ![superViewTemp isKindOfClass:[UIWindow class]]){

        if ([superViewTemp isKindOfClass:[UITableViewCell class]]) {
            cell=(UITableViewCell*)superViewTemp;
            isFoundCell = TRUE;

        }else if ([superViewTemp isKindOfClass:[UITableView class]]){
            tv = (UITableView*)superViewTemp;
            isFoundTable = TRUE;
        }

        superViewTemp = [superViewTemp superview];

        if(isFoundCell && isFoundTable){
            break;
        }
    }

    if(tv != nil && cell != nil){

        return [tv indexPathForCell:(UITableViewCell*)cell];
    }
    return nil;
}

这应该是一个非常简单的解决方案

UIView*视图=文本字段

而(![view IsKindof类:[UITableViewCell类]])

{

}


CellClass*单元格=(CellClass*)视图

这应该是一个非常简单的解决方案

UIView*视图=文本字段

而(![view IsKindof类:[UITableViewCell类]])

{

}


CellClass*单元格=(CellClass*)视图

只是一个小小的警告。这是iOS 6的有效解决方案。在iOS 7中不再工作。只是一个小警告。这是iOS 6的有效解决方案。在iOS 7中不再工作。