Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Func没有';当手机进入锁屏时无法工作_Ios_Swift_Cocoa - Fatal编程技术网

Ios Func没有';当手机进入锁屏时无法工作

Ios Func没有';当手机进入锁屏时无法工作,ios,swift,cocoa,Ios,Swift,Cocoa,我在ViewController中有事件: ObjectsContainer.messageDecrypt = { count in DispatchQueue.main.async { self.PleaseWait.text = String(describing: count) + "%" } } 以及ObjectsContainer的示例 ObjectsContainer { ... static var messageDecrypt :

我在ViewController中有事件:

ObjectsContainer.messageDecrypt = { count in
    DispatchQueue.main.async {
        self.PleaseWait.text = String(describing: count) + "%"
    }
}
以及ObjectsContainer的示例

ObjectsContainer {
    ...
    static var messageDecrypt : ((Double) -> ())?

    func DecryptMessages() {
        ...
        ObjectsContainer.messageDecrypt?(value)
    }
}
当设备进入锁屏然后退出待机模式时,此事件停止调用。但是,如果我在手机中打开桌面,然后再回来,这个活动就会起作用。 有什么问题吗


p.S.对不起,我的英语不好

您执行此代码的功能是什么?您是否请求过后台授权?当应用程序进入后台时,您是否将该功能设置为工作状态?我会在屏幕上显示解码的进度。首先,我执行Decryptmessages,它对所有消息进行解密,并在主线程上调用ObjectsContainer.messageDecrypt?(值)以显示ViewController中的进度。当应用程序进入后台时,我不会将函数设置为工作,因为我不知道如何执行。