从Tableview单元获取多于一个TextField的值?

时间:2016-08-17 12:34:03

标签: ios swift uitableview uitextfield

我在Textfield中有Table和First 2 Row。我想从两者中获得价值但是我怎么能得到那个

Image Representation

代码: -

 let cell = tableView.dequeueReusableCellWithIdentifier("csttblcell", forIndexPath: indexPath)
    cell.textLabel?.text = cellTitle[indexPath.row]
    txtcontent = cell.contentView.viewWithTag(101) as! UITextField

3 个答案:

答案 0 :(得分:1)

使用类似的东西:

guard let cell1 = tableView.cellForRowAtIndexPath(NSIndexPath(forItem: 0, inSection: 0)) else { return }
guard let textField1 = cell1.viewWithTag(101) as? UITextField else { return }
print(textField1.text)

答案 1 :(得分:1)

把它放在你的IBAction中:

let button = sender as! UIButton   // Button that called the IBAction

var labelText = ""

if let cell = button.superview!.superview {   // Cell that the button is in
    currentCell = cell as! UITableViewCell
    if let label = currentCell.textLabel {   // Get the label in that cell
        labelText = label.text   // Assign the string to our variable, declared above
    }
}

答案 2 :(得分:0)

getId('textarea-sysID').value($(this).find('data-rowid').text()));
sysID = $(this.data-rowid); 
alert(sysID.innerHTML);
getId('textarea-sysID').value(sysID);
getId('textarea-sysID').value = JSON.stringify(sysID);