2017-06-26 46 views

回答

0

Refer This :-

創建一個全局陣列添加從數組中刪除元素上點擊您的按鈕

0

,你可以從一個視圖控制器將數據傳遞到另一個使用的代表。檢查我的答案here。您可以將您的表視圖類設置爲任務視圖控制器的代表。實現任務視圖控制器獲取數據和重載表的協議方法。 希望它有幫助。 快樂編碼!

0

您可以使用委派傳遞數據。

在第二的ViewController

import UIKit 

protocol secondViewDelegate: class { 
    func passData(arrData : [Any]) 
    } 

class SecondViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { 

    weak var delegate: secondViewDelegate? = nil 

     @IBAction func clickOnButton(_ sender: Any) { 
      self.delegate.passData([]) // replace your array here 
     } 
} 

在FirstViewController

class FirstViewController: UIViewController, UITableViewDataSource, secondViewDelegate 

    let objectSecondVC: SecondViewController? = storyboard?.instantiateViewController(withIdentifier: "secondVCID") as! SecondViewController? 
      objectSecondVC?.delegate = self 
      navigationController?.pushViewController(objectSecondVC?, animated: true) 

二視圖控制器的委託方法在FirstViewController

func passData(arrData : [Any]){ 
// append to your main array 
} 
0

它看毫秒像你的添加任務視圖控制器通過一個segue連接到你的表視圖控制器。因此,當您從添加任務視圖控制器移回時,可以使用unwind來傳回數據。 Here是一個帶有簡單說明和圖片的詳細教程。

相關問題