[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.

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。