当我单击按钮时,将打开该表视图,当我单击该表视图中的国家/地区时,我希望它返回到按钮]] << [

问题描述 投票:0回答:1
当我单击按钮时,将打开该表视图,当我单击该表视图中的国家/地区时,我希望它返回到该按钮。

enter image description hereenter image description here类PopOverViewController:UIViewController,UITableViewDelegate,UITableViewDataSource {

@ IBOutlet弱变量Popupview:UIView!

@IBOutlet weak var tableView: UITableView! var names: [String] = ["Mumbai","New York","Tokyo","London","Beijing","Sydney","Wellington","Madrid","Rome","Cape Town","Ottawa"] override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self tableView.delegate = self // Apply radius to Popupview Popupview.layer.cornerRadius = 10 Popupview.layer.masksToBounds = true } // Returns count of items in tableView func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.names.count; } // Select item from tableView func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { print("Company Name : " + names[indexPath.row]) Shared.shared.companyName = names[indexPath.row] let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let newViewController = storyBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController self.present(newViewController, animated: true, completion: nil) } //Assign values for tableView func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = names[indexPath.row] return cell } // Close PopUp @IBAction func closePopup(_ sender: Any) { dismiss(animated: true, completion: nil) }

}

[当我单击按钮时,将打开表视图,当我在表视图中单击一个国家/地区时,我希望它返回到按钮。在此处输入图像描述,在此处输入图像描述类...

swift xcode xcode8
1个回答
0
投票
然后在内部将其关闭
© www.soinside.com 2019 - 2024. All rights reserved.