在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
在Swift中使用闭包来实现两个界面的传值
例如:有A类和B类. B类 //声明闭包 typealias valueBlock = (Float)->() var returnPrice: valueBlock? //调用该闭包 self.returnPrice?(price) A类 let sb = UIStoryboard(name:"Main", bundle: nil) let vc = sb.instantiateViewControllerWithIdentifier("keypadViewVC") as! keypadViewVC //B类的回调 vc.returnPrice = {price in self.gratuityBtn.setTitle(String(format: "%.2f", price), forState:UIControlState.Normal)} self.presentViewController(vc, animated: true, completion: nil)
|
请发表评论