Swift Popup将值返回给父ViewController

时间:2019-03-19 20:02:18

标签: ios swift

我有一个弹出窗口,在其中搜索一些值。如果用户在弹出窗口中选择了某些内容,则该值应返回给父级Viewcontroller,但我不知道该怎么做。 为了显示我创建的弹出窗口:

 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)

在我的SelectSellerTypViewController中,我只想通过单击按钮返回值,所以没有特殊代码:

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()
        }
    })
}

}

0 个答案:

没有答案