I have a custom UIView with a UITapGestureRecognizer attached to it. The gesture recognizer calls a method called hide() to remove the view from the superview as such:
func hide(sender:UITapGestureRecognizer){
if let customView = sender.view as? UICustomView{
customView.removeFromSuperview()
}
}
The UICustomView also has a show() method that adds it as a subview, as such:
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)
}
Which means that I can create a UICustomView and display it as such:
let testView = UICustomView(frame:frame)
testView.show() // The view appears on the screen as it should and disappears when tapped
Now, I want to turn my show() method into a method with a completion block that is called when the hide() function is triggered. Something like:
testView.show(){ success in
println(success) // The view has been hidden
}
But to do so I would have to call the completion handler of the show() method from my hide() method. Is this possible or am I overlooking something?