Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.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 Swift:按下按钮后,如何将来自三个单独文本字段的数据发布到自定义单元格中的标签上?_Ios_Swift_Uitableview - Fatal编程技术网

Ios Swift:按下按钮后,如何将来自三个单独文本字段的数据发布到自定义单元格中的标签上?

Ios Swift:按下按钮后,如何将来自三个单独文本字段的数据发布到自定义单元格中的标签上?,ios,swift,uitableview,Ios,Swift,Uitableview,我是swift新手,我尝试在ViewController上从一个文本字段中获取文本,从另外两个文本字段中获取值(每个文本字段一个值),然后当按下按钮时,将所有三条信息水平显示在tableview的单元格中 这是我正在尝试做的一个例子: 我希望在按下按钮后,文本字段1、2和3中的数据显示在标签1、2和3中 @IBAction func btn_reload(sender: AnyObject) { /*lbl1.text = txtfield1.text! lbl2.text =

我是swift新手,我尝试在ViewController上从一个文本字段中获取文本,从另外两个文本字段中获取值(每个文本字段一个值),然后当按下按钮时,将所有三条信息水平显示在tableview的单元格中

这是我正在尝试做的一个例子:

我希望在按下按钮后,文本字段1、2和3中的数据显示在标签1、2和3中

@IBAction func btn_reload(sender: AnyObject) 
{
   /*lbl1.text = txtfield1.text!
   lbl2.text = txtfield2.text!
   lbl3.text = txtfield3.text!*/

   var arrmute: [AnyObject] = [AnyObject]()
   var arrmute2: [AnyObject] = [AnyObject]()
   var arrmute3: [AnyObject] = [AnyObject]()

   arrmute.append(txtfield1.text!)
   arrmute2.append(txtfield2.text!)
   arrmute3.append(txtfield3.text!)
   self.tbl_out.reloadData()

}
首先设置脚本中
UITabelView
的委托和数据源

如代码:cell中所示,给出行的reuseIdentifier

将您的
UITableView
打开

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
{
    return arrmute.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 
{
    var cell: UITableViewCell
    if cell == nil 
    {
        cell = UITableViewCell(style: .Default, reuseIdentifier: "cell")
    }
    cell.lbl1.text = arrmute[indexPath.row]
    cell.lbl2.text = arrmute2[indexPath.row]
    cell.lbl3.text = arrmute3[indexPath.row]
    return cell

}

你试过什么样的东西?您是否将表视图设置为使用数据源作为视图控制器?感谢您的回复!一个问题是,数据显示在三个单独的行中,而不是在一行中水平显示。