不会为与照片相关的警报调用addUIInterruptionMonitor的处理程序 [英] Handler of addUIInterruptionMonitor is not called for Alert related to Photos

查看:393
本文介绍了不会为与照片相关的警报调用addUIInterruptionMonitor的处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private func acceptPermissionAlert() {

    _ = addUIInterruptionMonitor(withDescription: "") { alert -> Bool in

        if alert.buttons["Don’t Allow"].exists { //doesnt get here second time

            alert.buttons.element(boundBy: 1).tapWhenExists()

            return true
        }

        return false
    }
}

这不适用于:

在应用程序的开头,它在完成通知的acepting权限时工作正常,但这里......不起作用。

In the beginning of the app, it works perfect while acepting permission for notifications, but here... doesnt work.

你知道为什么吗?

推荐答案

添加:

app.tap()

在方法结束时。


这是因为您需要与应用程序进行交互才能触发处理程序。

This is because you need to interact with the app for the handler to fire.

这篇关于不会为与照片相关的警报调用addUIInterruptionMonitor的处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆