从每行的tableview传递数据不同的数据,并在swift 3的另一个视图控制器表视图中显示

时间:2018-07-04 06:40:12

标签: swift3

这是表视图的第一个View控制器。

var labelArray = ["9 digit Account Number","MPIN(4)"]

var IMPSarray = ["Beneficiciary Mobile Number(10)","Beneficiciary MMID(7)","Amount","x","y"]


func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

{

  service = bankServices1[indexPath.row]

  if indexPath.row == 0

  {

     let FVC = storyboard?.instantiateViewController(withIdentifier: "fifth")as! FifthViewController

     FVC.labelArray = labelArray[IndexPath.row]

     self.present(FVC!, animated: true, completion: nil)

  }

  if indexPath.row == 2

  {

     let FVC = storyboard?.instantiateViewController(withIdentifier: "fifth") as! FifthViewController

     FVC.IMPSarray = IMPSarray[indexPath.row]

     self.present(FVC!, animated: true, completion: nil)

  }

这是第二个View控制器。

 var labelArray:[String] = []

 var IMPSArray:[String]  = []

 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
 {
    let tvc = storyboard?.instantiateViewController(withIdentifier: "third") as! ThirdViewController

    if tvc.service.count == 0
    {
        return labelArray.count
    }
    else
    {
        return IMPSarray.count
    }

}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let tvc = storyboard?.instantiateViewController(withIdentifier: "third") as! ThirdViewController
    let service2 = tableView4.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ServiceTableViewCell
    if tvc.service.count == 0
    {
        service2.serviceLabelName.text = labelArray[indexPath.row]
    }
    else if tvc.service.count == 2
    {
        service2.serviceLabelName.text = IMPSarray[indexPath.row]
    }

    return service2
}

0 个答案:

没有答案