I try to close a UIViewController
after an UIAlertController
has been shown.
This is my code:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:msg
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Accept"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
[self dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:^{}];
However, self
never gets dismissed. Anyone knows how to solve this?
UPDATE
if I set [self dismissViewControllerAnimated:YES completion:nil];
outside of the block, it works.
Just use [super.navigationController popViewControllerAnimated:YES];