मेरे पास एक UITapGestureRecognizer से जुड़ा एक कस्टम UIView है।क्या आईओएस में किसी अन्य फ़ंक्शन से ब्लॉक समापन हैंडलर को कॉल करना संभव है?
func hide(sender:UITapGestureRecognizer){
if let customView = sender.view as? UICustomView{
customView.removeFromSuperview()
}
}
UICustomView भी एक विधि शो() है कि यह एक subview के रूप कहते है, जैसे::
func show(){
// Get the top view controller
let rootViewController: UIViewController = UIApplication.sharedApplication().windows[0].rootViewController!!
// Add self to it as a subview
rootViewController.view.addSubview(self)
}
इशारा पहचानकर्ता एक विधि कहा जाता छिपाने() जैसे superview से देखने को हटाने के लिए कॉल
इसका मतलब है कि मैं एक UICustomView बना सकते हैं और इस तरह के रूप में प्रदर्शित कर सकते हैं:
let testView = UICustomView(frame:frame)
testView.show() // The view appears on the screen as it should and disappears when tapped
अब, मुझे लगता है कि कहा जाता है एक पूरा होने के ब्लॉक के साथ एक विधि में मेरी शो() विधि चालू करना चाहते हैं जब छिपाने () समारोह ट्रिगर किया गया है। कुछ की तरह:
testView.show(){ success in
println(success) // The view has been hidden
}
लेकिन ऐसा करने के लिए इसलिए मैं अपने छिपाने() विधि से विधि शो() के पूरा होने के हैंडलर फोन करना होगा। क्या यह संभव है या क्या मैं कुछ दिख रहा हूं?
चालाक! और एक आकर्षण की तरह काम करता है, धन्यवाद @GoZoner :) – Audioy