0

I need to draw image async, but [UIImageView setImage:someImage] is not thread safe. So I have to implement a thread safe draw function by myself.

Is it possible in iOS? And how? I know how to use Quartz do custom drawing.

Special thanks!

OpenThread
  • 2,096
  • 3
  • 28
  • 49
  • please visit my answer asynchronous image http://stackoverflow.com/questions/12947523/asyncronous-image-loading-in-uitableview-cell/12947646#12947646 – Nitin Gohel Oct 18 '12 at 06:27
  • but SDWebImage render image in main thread – OpenThread Oct 18 '12 at 06:33
  • All interface changes must be done in Main Thread. Performing interface changes on the background thread will not update the interface. SDWebImage is an asynchronous image downloading and caching library, isn't that what you want, async UIImage like your title suggested? – Zhang Oct 18 '12 at 08:31

2 Answers2

1

Usually you just need to load the images in the background. And then draw them on the foreground thread. Have a look here loading images from a background thread using blocks

Community
  • 1
  • 1
HeikoG
  • 1,793
  • 1
  • 20
  • 29
  • i want to draw them in background to make their container scroll view more smooth – OpenThread Oct 18 '12 at 06:35
  • Could you tell more about the context of what you are trying to achieve ? I'm still thinking, loading in background might be what you want ... – HeikoG Oct 18 '12 at 20:58
  • UIImage already loaded from local file and resized small using QuartzCore in background thread. Now I want to render UIImage in memory to screen in background. – OpenThread Oct 19 '12 at 01:56
0

You can use the drawsAsynchronously property of CALayer and implement your own imageView/imageLayer. This may help to improve the responsiveness of your GUI.

Jonathan Cichon
  • 4,396
  • 16
  • 19