is. The English word means "dissolve" or "dismiss, dismiss". If you execute this on the transition destination screen, you will return to the screen before the transition. When implemented, it looks like this.
NextViewController
//Action connected to the "Back" button
@IBAction func returnAction(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
I wrote it like a fixed phrase, but I didn't understand sender
, animated
, and completion
.
sender
Meaning "sender" (send + er).
The default is Any
, but it seems that it is actually preferable to specify the type.
In this case, specify UIButton
. You can select from the pull-down when dragging and dropping with the control key.
At first glance, it may be easier to understand if it says UIButton
.
This article is detailed. ↓
** IBAction sender should specify a concrete type instead of Any (Swift) ** https://qiita.com/uhooi/items/e90d06e5d5681d72cbd0
animated
Presence or absence of animation.
If you set it to false
, the behavior will be unclear.
completion
In English, it means "complete". It's a complete thing.
The default when generated semi-automatically is not nil
completion: (()->void)?
It is written.
This seems to be related to ** closure .
It seems that " the inside of the parentheses is called after the value is entered, and the outside of the parentheses is called until the value is entered **", but I can't understand it.
For now, remember that "completion is about closures." ..
Recommended Posts