주 ViewController
메인과 화면을 오버레이하는 팝업을 제어하는 보조 VC를 만드는 빠른 프로그램을 만들려고합니다. 이 팝업에서 tableView
(기본 ViewController
)으로 표시되는 로그인 자격 증명을 입력 할 수 있습니다. 하지해야합니다 (별도의 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