iOS获取TableViewCell上多个输入框的信息

1初始化数组.

- (NSMutableArray *)segWidthArr{

    if (_segWidthArr == nil) {

        _segWidthArr = [NSMutableArray array];

    }

    return _segWidthArr;

}

- (NSMutableArray *)segLengthArr{

    if (_segLengthArr == nil) {

        _segLengthArr = [NSMutableArray array];

    }

    return _segLengthArr;

}

- (NSMutableArray *)segThicknessArr{

    if (_segThicknessArr == nil) {

        _segThicknessArr = [NSMutableArray array];

    }

    return _segThicknessArr;

}

2.取出tableView行数

NSInteger rows = [self.tableV numberOfRowsInSection:0];

//遍历每一行cell,取出cell

    for (int row = 0; row < rows; row++) {

        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];

        TKYRemoveFilmThreeTFCell *cell = [_tableV cellForRowAtIndexPath:indexPath];

//遍历cell的所有视图, 判断是不是UITextField 如果是取值放入数组

        for (UIView *view in cell.contentView.subviews) {

            if ([view isKindOfClass:[UITextField class]]) {

                UITextField *tf = (UITextField *)view;

                NSString *str = tf.text;

                if (str.length > 0) {

                if (row == 1) {

                    [self.segWidthArr addObject:str];

                } else if (row == 2) {

                    [self.segLengthArr addObject:str];

                }else if(row == 3){

                    [self.segThicknessArr addObject:str];

                }

            }

          }

        }

    }

你可能感兴趣的:(iOS获取TableViewCell上多个输入框的信息)