是UIGraphicsBeginImageContext线程安全吗? [英] Is UIGraphicsBeginImageContext thread safe?

查看:395
本文介绍了是UIGraphicsBeginImageContext线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直觉得UIGraphicsBeginImageContext是线程安全的,可以从任何线程调用来创建一个新的CGContextRef,可以用来绘制。

So I've been under the impression that UIGraphicsBeginImageContext is thread safe, and can be called from any thread to create a new CGContextRef that can be used to draw.

但是,目前的文档说明

您应该从您的主线程调用此函数应用程序。

但是,在WWDC 2012会话视频构建并发用户界面背景,并在后台调用该方法:

However, in the WWDC 2012 session video "Building Concurrent User Interfaces", the speaker shows that you can actually draw in the background, and call that method in the background:

>

你可以看到,他向一个 _queue (在BG线程上运行)添加一个操作,它调用 renderedGraphOfSize ,它调用 UIGraphicsBeginImageContext 。那么什么交易?我在我的应用程序中遇到一些崩溃,当它涉及到在后台绘制,所以我不知道为什么有困惑的例子从苹果。

So as you can see, he adds an operation to a _queue (which runs on a BG thread), which calls renderedGraphOfSize, which calls UIGraphicsBeginImageContext. So what's the deal? I am getting some crashes in my app when it comes to drawing in the background, so I don't know why there are confused examples from Apple.

推荐答案

UIGraphicsBeginImageContext绝对是线程安全的iOS 4及更高版本。
WWDC 2012会话视频涉及iOS 6,所以也许你应该涉及到iOS 6文档:)

UIGraphicsBeginImageContext definitely is thread safe in iOS 4 and later. WWDC 2012 session videos relate to iOS 6, so maybe you should relate to iOS 6 documentation as well :)

这篇关于是UIGraphicsBeginImageContext线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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