func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.showPopUp()
let semaphore = DispatchSemaphore(value: 0)
self.api.requestMedicationsByReagent(method: 1, ean: "", hash: medHash!, gen: generic) { output in
semaphore.signal()
self.objects = output
}
let _ = semaphore.wait(timeout: DispatchTime.distantFuture)
}
showPopUp的作用是:
func showPopUp() {
let popOverVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "loadingPopUp") as! PopUpViewController
self.addChildViewController(popOverVC)
popOverVC.view.frame = self.view.frame
self.view.addSubview(popOverVC.view)
popOverVC.didMove(toParentViewController: self)
}