Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

However, the current documentation states that

"You should call this function from the main thread of your application only."

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:

enter image description here

enter image description here

enter image description here

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
440 views
Welcome To Ask or Share your Answers For Others

1 Answer

To quote from the documentation:

In iOS 4 and later, you may call this function from any thread of your app.

link:http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...