// Breaks
[viewController1 dismissViewControllerAnimated:YES completion:NULL];
[self presentViewController:viewController2 animated:YES completion:NULL];
// Does not break
[viewController1 dismissViewControllerAnimated:YES completion:^{
[self presentViewController:viewController2 animated:YES completion:NULL];
}];
The Swift 3 version of the above code would look like this:
// Breaks
viewController1.dismiss(animated: true)
present(viewController2, animated: true)
// Does not break
viewController1.dismiss(animated: true) {
present(viewController2, animated: true)
}
Note the use of the completion handler in the second example above.
It only presents viewController2
after viewController1
has been fully dismissed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…