i have a popup where i search for some values. if the user selected something in the popup, the value should returned to the parent Viewcontroller but i have no idea how to do it. To show the popup i created this:
let popUpPreload = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "selectsellertyp") as! SelectSellerTypViewController
self.addChild(popUpPreload)
popUpPreload.view.frame = self.view.frame
self.view.addSubview(popUpPreload.view)
popUpPreload.didMove(toParent: self)
In my SelectSellerTypViewController i just wanna return the value through a button click so there is no special code:
SelectSellerTypViewController: UIViewController {
@IBAction func cancelaction(_ sender: Any) {
removeAnimation()
}
@IBAction func startSearching(_ sender: Any) {
// HEre i want to return the value
}
@IBAction func cancel(_ sender: Any) {
removeAnimation()
}
@IBOutlet weak var rv: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
showAnimate()
// Do any additional setup after loading the view.
}
func showAnimate(){
self.view.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.view.alpha = 0.0
UIView.animate(withDuration: 0.25, animations: {
self.view.alpha = 1.0
self.view.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
});
}
func removeAnimation(){
UIView.animate(withDuration: 0.25, animations: {
self.view.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
self.view.alpha = 0.0
},completion:{(finished: Bool)in
if finished{
self.view.removeFromSuperview()
}
})
}
}