I created an activity where when one of the text fields clicked it will pop up a child(alert dialog) with list of product but when i click one item on the list I can\'t disp
In ChildVC(ViewPopUpProduct) add instance of ParentVC
class ViewPopUpProduct: UIViewController {
var parentVC = ViewAward? //ParentView
var someValueToSend : String?
.
.
.
fun sendData(){
// After fetching some value call this function from child
parentVC.result = someValueToSend
self.view.removeFromSuperview()
}
}
In Parent View While you invoke child(subview) share the instance
class ViewAward: UIViewController{
var result = String?//Variable to store result from child
func productTapped(textfield: UITextField){
//tfProduct.endEditing(true)
tfProduct.resignFirstResponder()
let popOverVC = UIStoryboard(name:"Main",bundle:nil).instantiateViewControllerWithIdentifier("sbPopUpID") as! ViewPopUpProduct
popOverVC.parentVC = self//Sharing Parent Views Instance
self.addChildViewController(popOverVC)
popOverVC.view.frame = self.view.frame
self.view.addSubview(popOverVC.view)
popOverVC.didMoveToParentViewController(self)
}
}
now after removing the child view Access the Result variable and enjoy!