メインViewController
を持つスウィフトプログラムと、画面をオーバーレイするポップアップを制御するセカンダリVCを作成しようとしています。このポップアップでは、ログイン資格情報を入力することができます。これは、ViewController
のtableView
に表示されます。いけません(別のViewControllerからViewTableをリフレッシュする方法
は、これまでのところ私はコアデータに二次VCに入力した値を保存することができるよ、それはちょうどカントreloadData()
関数を参照してくださいので、私は、最初のVCでtableView
ためreloadData()
にできないんだけど私が迅速に動くようになったので、わからない)。
誰かがこれを行う最善の方法を見つけ出すのに役立つでしょうか?
メインのViewControllerコード:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var account = [Account]()
@IBAction func onAddAccount(_ sender: Any) {
self.tableView.reloadData()
print("RELOADED")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func onBlank() {
self.tableView.reloadData()
}
}
extension ViewController: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return account.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .subtitle, reuseIdentifier: nil)
cell.textLabel?.text = account[indexPath.row].email
cell.detailTextLabel?.text = account[indexPath.row].password
return cell
}
}
これは 'UITableViewDelegate'がないためですか? – Amit