1. 程式人生 > >[iOS] How to properly dismiss modal viewcontroller with completion handler

[iOS] How to properly dismiss modal viewcontroller with completion handler

有引數要傳給 dismiss 的 completion 要怎麼寫?

Pretty easy, pass funcToCall() as a completion parameter (important note – I’m using curly braces here):

viewController.dismissViewControllerAnimated(true, completion: { 
    funcToCall()
})

completion parameter documentation:

The block to execute after the view controller is dismissed. This block has no return value and takes no parameters. You may specify nil for this parameter.