Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.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/0/xml/15.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 UIActivityItemSource在背景中渲染图像_Ios_Swift_Uikit_Grand Central Dispatch - Fatal编程技术网

Ios UIActivityItemSource在背景中渲染图像

Ios UIActivityItemSource在背景中渲染图像,ios,swift,uikit,grand-central-dispatch,Ios,Swift,Uikit,Grand Central Dispatch,我的应用程序大约需要10秒来渲染一个应用了许多过滤器的全分辨率图像。我想允许用户使用UIActivityViewController保存或共享它。我已经对UIActivityItemSource进行了子类化,因此它在活动视图打开时提供了一个缩略图 如何使我的项目源在背景中渲染图像?具体来说,我希望允许视图控制器最小化并显示进度条 我已经让进度条工作了,我只需要知道如何在后台执行以下操作: func activityViewController(activityViewController: UI

我的应用程序大约需要10秒来渲染一个应用了许多过滤器的全分辨率图像。我想允许用户使用
UIActivityViewController
保存或共享它。我已经对
UIActivityItemSource
进行了子类化,因此它在活动视图打开时提供了一个缩略图

如何使我的项目源在背景中渲染图像?具体来说,我希望允许视图控制器最小化并显示进度条

我已经让进度条工作了,我只需要知道如何在后台执行以下操作:

func activityViewController(activityViewController: UIActivityViewController, itemForActivityType activityType: String) -> AnyObject? {

    // this step takes 10 seconds
    // is there any way to do it in the background?
    // So: the activity view can minimize
    // and the main thread is free to update my progress bar

    let image = renderFullImage()

    return image
}

诀窍是使用
UIActivityItemProvider
而不是
UIActivityItemSource
。您应该重写
方法,该方法已在后台调用