是UIGraphicsBeginImageContext线程安全吗?

编程入门 行业动态 更新时间:2024-10-15 20:19:26
本文介绍了是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线程安全吗?

本文发布于:2023-11-12 10:48:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581276.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   UIGraphicsBeginImageContext

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!