Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Create UIImage from the background thread?

Apples documentation says:

Because image objects are immutable, you cannot change their properties after creation. Most image properties are set automatically using metadata in the accompanying image file or image data. The immutable nature of image objects also means that they are safe to create and use from any thread.

Link

Also if you look at the answers of this "Thread safety of UIImage" question, it is concluded that it is safe to use them from any thread (at least since iOS 9).

Yet, there are comments that complain about issues, especially about creating UIImages on a background thread.

In my case I'm sure that this leads an issue where animations stop working. Does anybody have insights on this?

like image 696
fancy Avatar asked Oct 17 '22 22:10

fancy


1 Answers

I can't see your code but I suspect this is a UIImage vs UIImageView issue if you're experiencing animation problems.

A UIImage manages image data off screen.
A UIImageView displays your image on to your user interface.

Handling image data off the main thread with UIImage is fine.
Displaying or animating an image with UIImageView is not.

like image 122
Declan McKenna Avatar answered Oct 21 '22 01:10

Declan McKenna