UIAlertController showing with delay

Deadly 提交于 2019-12-02 19:56:48

I was having the same issue with a UIAlertController presented by selecting a row from a UITableView. The first time everything worked fine, and then when the user triggered the alert again there was a few seconds delay before the alert was actually presented.

As a workaround I used GCD:

    dispatch_async(dispatch_get_main_queue(), ^{
        [self presentViewController:AlertView animated:YES completion:nil];
    });

It is probably a bug since -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath is already executed on the main thread.

I submitted a bug report to Apple: rdar://19285091

    DispatchQueue.main.async {
        self.present(alertView, animated: true, completion:nil)
    }

Swift 3.0 version. Alternatively, setting animated: false also solved my problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!