I don't know why dismissViewControllerAnimated:completion:
. I just want to do it.
I start with a
[self performSegueWithIdentifier:@"my_segue" sender:self];
But is I call the dismiss than nothing happens. I can create another segue, but it create a new view controller.
My question is: How dismiss the performSegueWithIdentifier:sender:
?
Do you have a navigationBar in the viewController that's calling:
[self performSegueWithIdentifier:@"my_segue" sender:self];
If so, you'll need to use:
[self.navigationController popViewControllerAnimated:YES];
to pop the view off the stack. There's one segue call, but the framework seems to call:
presentViewController:animated:completion:
or:
pushViewController:animated:
as appropriate.
Ray
You could just call
[self dismissViewControllerAnimated:YES completion:nil];
from the view controller since the view controller was pushed by segue.
[my_segue_view_controller dismissModalViewControllerAnimated: YES]
?
(not sure, but it works in my practice)
performSegueWithIdentifier:sender:
itself isn't dismissed, that's just the method that's called to initiate a named segue. What happens in the segue is of more interest.
You're right that you should call dismissViewControllerAnimated:completion:
, and it should be called by the presenting view controller, which has previously called the presented view controller using presentViewController:animated:completion:
. For more info, see the UIViewcontroller docs .
使用以下代码为Swift 4版本
self.navigationController?.popViewController(animated: true)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.