2017-09-12 3 views
0

UITableViewが2つあります。最初にタップすると2番目に開くセルがあります。UITableView。 2番目のUITableViewのセルが選択されると、2番目のtableView画面はそのセルからのテキストを閉じて持ち運び、最初のUITableViewのセルラベルにラベルを設定します。次のように私がこれまで持っているコードがあり、それは、スレッド・エラーを与える:didItelectRow内の1つのUITableViewから別のUITableViewにデータを渡しますか?

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
    let destVC = EnrollmentAccountTableViewController() 
    destVC.lblAccountType.text = GlobalParams.enrollmentAccountTypes[indexPath.row].acctName 

    self.navigationController?.popViewController(animated: true) 
} 

答えて

1

はこの試してください: -

var strAccname:String! 

override func viewWillAppear(_ animated: Bool) { 
if strAccname != nil { 
    self.lblAccountType.text = strAccname 
    } 
    } 
+0

が@PushpendraMishraあなたのソリューションが働いてありがとう、あなたのEnrollmentAccountTableViewControllerに

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { for obj in (self.navigationController?.viewControllers)! { if obj is EnrollmentAccountTableViewController { let vc2: EnrollmentAccountTableViewController = obj as! EnrollmentAccountTableViewController vc2.strAccname = GlobalParams.enrollmentAccountTypes[indexPath.row].acctName _ = self.navigationController?.popToViewController(vc2, animated: true) break } } } 

を私のために非常によく。再度、感謝します! –

+0

は、もう2分間受け入れることができません。少なくとも私は0になるので、私の質問に投票してください。ありがとうございました。 –

関連する問題