在显示UIAlertController
后,我尝试关闭一个UIViewController
。
这是我的代码:
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:^{}];
然而,self
从未被解雇。 有人知道如何解决吗?
更新
如果我将[self dismissViewControllerAnimated:YES completion:nil];
设置在块之外,它就有效了。